import java.util.*; import java.math.*; public class Solution { public static int smallFactor (long n) { int m = (int) Math.sqrt(n); int result = 1; for (int i=2; i<=m; i++) { if (n%i == 0) { result = i; break; } } return result; } static long longestSequence(long[] a) { long result = 0; for (int i=0; i 1) { int div = smallFactor(n); if (div == 1) { total = total + n; n = 0; } else { total = total + n; n = n/div; } } result = result + total; } 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 = longestSequence(a); System.out.println(result); in.close(); } }