import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long fp = 0; static void findPrimes(int prime[],long n){ //System.out.println("Hello Prime Start"); // Print the number of 2s that divide n fp = 0; while (n%2 == 0) { prime[2]+=1; n = n/2; } // n must be odd at this point. So we can skip // one element (Note i = i +2) for (int i = 3; i <= Math.sqrt(n); i = i+2) { // While i divides n, print i and divide n while (n%i == 0) { prime[i]+=1; n = n/i; } //System.out.println("Hello loop 2"); } // This condition is to handle the case when n // is a prime number greater than 2 //System.out.println("Hello Prime End"); if (n > 2) fp = n; } static long longestSequence(long a) { // Return the length of the longest possible sequence of moves. if(a==1){ return 1; } //System.out.println("Hello 1"); int np = (int)Math.sqrt(a),i=0; int prime[]=new int[np+2]; findPrimes(prime,a); long result = 1,curr = 1; for(i=np+1;i>=2;i--){ if(i<=fp){ curr = curr*fp; result+=curr; fp = Long.MIN_VALUE; i++; }else if(prime[i]!=0){ while(prime[i]!=0){ curr = curr*i; result+=curr; prime[i]--; } } //System.out.println("Hello Loop 1"); } //System.out.println("Hello End"); return (result); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] a = new long[n]; for(int a_i = 0; a_i < n; a_i++){ a[a_i] = in.nextLong(); } long result = 0,val = 0; for(int i=0;i