#!/bin/python3 import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. MAX = int(1e6) + 1 a = {int(x):set() for x in a} p = [True] * MAX p[0] = p[1] = False for i in range(2, MAX): if p[i]: for j in range(i << 1, MAX, i): p[j] = False for j in a.keys(): if j % i == 0: a[j].add(i) tmp = list(); ans = 0 for k, v in a.items(): tmp.clear(); j = k for d in v: count = 0 while k % d == 0: tmp.append(d) k //= d count += 1 if k != 1: tmp.append(k) val, mul = j, 1 for x in tmp: mul *= x val += (j // mul) ans += val return ans if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)