#!/bin/python import sys def getFactors(num): lst = [] limit = int(num**(0.5)) for x in range(2,limit+1): if num % x == 0: lst.append(x) lst.append(num//x) if lst: return lst else: return [1] def getMoves(x): if x == 1: return 1 fc = getFactors(x) cntArr = [] for num in fc: cnt = 0 if num == 1: cnt += x+1 else: cnt += 1 y = getMoves(x/num) cnt += num*y cntArr.append(cnt) return max(cntArr) def longestSequence(a): # Return the length of the longest possible sequence of moves. memo = {} cnt = 0 for x in a: cnt += getMoves(x) return cnt if __name__ == "__main__": n = int(raw_input().strip()) a = map(long, raw_input().strip().split(' ')) result = longestSequence(a) print result