#!/bin/python3 import sys def gcd(x): g = x for i in range(2, int(x**0.5)+1): if (x % i == 0): g = min(g, i, x//i) return (g) def primefactors(x): factors = [] for i in range(2, int(x**0.5)+1): if (x % i == 0): return (list([i]+primefactors(x//i))) return [x] def longestSequence(x, depth): pos = 0 moves = 0 ones = 0 g = gcd(x) h = x//g #(g,h) = list([h,g]) if (x == 1): print ('{:3} seq (1) --> 1'.format(depth, x, g), file=sys.stderr) return (1) if (g == x): print ('{:3} seq ({}) --> 1+{}'.format(depth, x, g), file=sys.stderr) return (1+g) else: print ('{:3} seq ({}) --> 1+{}*seq({})'.format(depth, x, h, g), file=sys.stderr) return (1 + h * longestSequence(g, depth+1)) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) results = [] for x in a: factors = sorted(primefactors(x), reverse=True) #print ('{} --> {}'.format(x, factors), file=sys.stderr) width = 1 moves = 0 if (x > 1): for f in factors: moves += width #print ('{:5} {}'.format(moves, (str(x//width)+' ')*width), file=sys.stderr) width = width * f moves += width #print ('{:5} {}'.format(moves, '1 '*width), file=sys.stderr) results.append(moves) #print (results, file=sys.stderr) print(sum(results))