import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Solution { static HashMap vs = new HashMap<>(); static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. Arrays.sort(a); vs.put((long)1, (long)1); vs.put((long)2, (long)3); vs.put((long)3, (long)4); long sum = 0; for(long v : a) { sum += f(v); } return sum; } static long f(long v) { if(vs.containsKey(v)) { return vs.get(v); } int n = (int)Math.sqrt(v); long max = v + 1; for(int i = 2; i <=n ; i++) { if(v % i == 0) { long tmax = Math.max(i * f(v/i) + 1, v/i * f(i) + 1); if(tmax > max) { max = tmax; } } } vs.put(v, max); return max; } 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(); } }