import java.util.*; public class Solution { static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. int maxA = 0; for (int i = 0; i < a.length; i++){ if (a[i] > maxA){ maxA = (int)a[i]; } } int total = 0; int[] maxMoves = new int[maxA]; maxMoves[0] = 1; int n; int maxDivisor; for (int i = 1; i < maxA; i++) { n = i + 1; maxDivisor = 1; for (int j = n/2; j > 0; j--){ if (n % j == 0 && j > maxDivisor){ maxDivisor = j; } } maxMoves[i] = maxMoves[maxDivisor-1] + n; } for (int i = 0; i < a.length; i++){ total += maxMoves[(int)a[i]-1]; } return (long)total; } 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(); } }