#!/bin/python import sys import math from random import randrange def miller_rabin(n, k=10): if n == 2: return True if not n & 1: return False def check(a, s, d, n): x = pow(a, d, n) if x == 1: return True for i in xrange(s - 1): if x == n - 1: return True x = pow(x, 2, n) return x == n - 1 s = 0 d = n - 1 while d % 2 == 0: d >>= 1 s += 1 for i in xrange(k): a = randrange(2, n - 1) if not check(a, s, d, n): return False return True def getFactors(n, dp): for i in xrange(2,int(math.sqrt(n))+1): if n%i == 0: if n/i in dp: dp[n] = n+dp[n/i] return dp[n] else: return n + getFactors(n/i, dp) else: dp[n] = n+1 return dp[n] def longestSequence(a): # Return the length of the longest possible sequence of moves. ans = 0 dp={1:1,2:3,3:4,4:7,5:6,6:10,7:8,8:15,9:13,10:16} a.sort() for i in a: if i in dp: ans += dp[i] else: if miller_rabin(i): dp[i] = i+1 else: dp[i] = getFactors(i,dp) ans += dp[i] #print dp return ans if __name__ == "__main__": n = int(raw_input().strip()) a = map(long, raw_input().strip().split()) result = longestSequence(a) print result