from math import sqrt memos = {1:1, 2:3} def solve(stick): if stick not in memos: best = 1 + stick for num in range(2, stick//2 + 1): # TODO make faster factorization if stick % num == 0: possible = 1 + solve(stick//num) * num best = max(best, possible) memos[stick] = best return memos[stick] n = int(input()) sticks = map(int, input().split(" ")) steps = 0 for stick in sticks: steps += solve(stick) print(steps)