import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { int MAXSIZE = 1000000; int PRIMESIZE = 100000; boolean prime[] = new boolean[MAXSIZE]; int p[] = new int[PRIMESIZE]; int cp = 0; int div[] = new int[PRIMESIZE]; for(long i = 2; i < MAXSIZE; ++i ) { if(!prime[(int)i]) { p[cp++] = (int)i; for(long j = i*i; j < MAXSIZE; j += i) { prime[(int)j] = true; } } } long res = 0; for(long a_ : a) { int cd = 0; int pz = 0; long _a = a_; // System.out.print("Intermediate result :" + a_); long intr = 1 + ((a_>1)?a_:0); while(a_ > 1 && pz < cp) { while(a_%p[pz] == 0) { div[cd++] = p[pz]; a_ /= p[pz]; } ++pz; } long ff = 1; for(int k = cd-1; k >= 0; --k) { ff *= div[k]; if(ff != _a) intr += ff; // System.out.println("Down to calculus: " + intr + " " + div[k] + " " + ff); } // System.out.println(" " + intr); res += intr; } return res; } 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 = longestSequence(a); System.out.println(result); in.close(); } }