import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { Arrays.sort(a); HashMap moveCounts = new HashMap<>(); long moves = 0; for (long piece : a) { moves += split(piece, moveCounts); } return moves; } static long split(long piece, HashMapmoveCounts) { if (piece == 1) return 1; if (piece == 2) return 3; if (moveCounts.containsKey(piece)) return moveCounts.get(piece); double limit = Math.sqrt(piece) + 1; long divisor = 2; long high = 0; while (divisor <= limit) { if (piece % divisor == 0) { long temp = divisor * split(piece / divisor, moveCounts); if (temp > high) { high = temp; } } divisor++; } if (high == 0) { moveCounts.put(piece, piece + 1); } else { moveCounts.put(piece, high + 1); } return moveCounts.get(piece); } 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(); } }