import java.util.*; public class BreakingSticks { // Return the length of the longest possible sequence of moves. static long longestSequence(long[] a) { int totalSequence = 0; // iterate through each chocolate and calculate the most moves for each // chocolate, and total it up for (long l : a) { totalSequence += splitChocolate(l); } return totalSequence; } private static long splitChocolate(long l) { // base case: cannot split the chocolate if (l == 1) { return 1; // 1 move to eat the single piece } else { // holds the maximum moves for splitting this size chocolate long maxMoves = Long.MIN_VALUE; for (long d = 1; d < l; d++) { if (l % d == 0) { // find the total moves when going down this path long currMoves = 1 + (l / d) * splitChocolate(d); if (currMoves > maxMoves) { maxMoves = currMoves; } } else { // not a valid size. Ignore. } } return maxMoves; } } public static void main(String[] args) { // get the input 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(); } in.close(); // get the longest sequence of moves for all the chocolates long result = longestSequence(a); System.out.println(result); // print the result } }