#!/bin/python3 import sys class solver: def __init__(self, a): self.cache = [-1] * max(a) self.cache[0] = 1 def solve(self, size): # if the problem for this particular size # has already been solved, just re-use the answer. if self.cache[size-1] != -1: return self.cache[size-1] # iteratively look at all possible ways to break the bar # and take the best. cur_max = -float('inf') for i in range(2, size+1): # if the bar can be broken up into # i parts of equal size, if size % i == 0: cur_max = max(cur_max, i * self.solve(size // i) + 1) self.cache[size-1] = cur_max return cur_max if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) S = solver(a) # accumulator acc = 0 for elt in a: acc += S.solve(elt) print(acc)