#!/bin/python3 import sys import math from collections import namedtuple sys.setrecursionlimit(10000) def prime_factors(n): """Returns all the prime factors of a positive integer""" factors = [] d = 2 while n > 1: while n % d == 0: factors.append(d) n //= d d = d + 1 if d * d > n: if n > 1: factors.append(n) break return factors def most(n): if n == 1: return 1 p = prime_factors(n) if len(p) <= 1: return n + 1 p.sort(reverse=True) moves = 0 g = 1 for i in p: moves += g g *= i return moves + n def longestSequence(a): # Return the length of the longest possible sequence of moves. a = [most(n) for n in a] # print(a) return sum(a) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)