import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Map; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Hieu Le */ public class Solution { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); BreakingSticks solver = new BreakingSticks(); solver.solve(1, in, out); out.close(); } static class BreakingSticks { private Map cache; public void solve(int testNumber, InputReader in, PrintWriter out) { cache = new HashMap<>(); int n = in.nextInt(); long result = 0; for (int i = 0; i < n; ++i) result += explore(in.nextLong()); out.println(result); } private long explore(long length) { if (length == 1) return 1; if (cache.containsKey(length)) return cache.get(length); long result = 1 + length; for (long a = 2; a * a <= length; ++a) { if (length % a == 0) { long b = length / a; result = Math.max(result, 1 + a * explore(b)); result = Math.max(result, 1 + b * explore(a)); } } cache.put(length, result); return result; } } static class InputReader { private BufferedReader reader; private StringTokenizer tokenizer; private static final int BUFFER_SIZE = 32768; public InputReader(InputStream stream) { reader = new BufferedReader( new InputStreamReader(stream), BUFFER_SIZE); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } } }