def bitize(x): L = [] while x > 0: L.append(x % 2) x //= 2 if not L : L = [0] return L def is_prime(x,L = []): sqrt = int(pow(x,0.5)) + 1 PL = [2,3,5,7,11,13,17,19,23,29,31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199] if not L: if x < 210: if x in PL: return True else: return False else: for p in PL: if x % p == 0: return False for i in range(1, sqrt // 210 + 1): for j in [1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209]: if x % (210 * i + j) == 0: return False return True elif x != 0 and x != 1: j = 0 while j < len(L) and L[j] <= sqrt: if x % L[j] == 0: return False j += 1 else: return False return True def prime_list(n): L = [2,3,5,7,11,13,17,19,23,29,31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199] for k in range(1, n // 210): for j in [1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209]: if is_prime(210 * k + j, L): L.append(210 * k + j) k = n // 210 for j in [1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209]: if is_prime(210 * k + j, L) and 210 * k + j <= n: L.append(210 * k + j) return L def pow_mod(a,b,m): b_bits = bitize(b) a_powers = [0 for x in b_bits] a_powers[0] = a % m if b_bits[0]: total = a % m else: total = 1 for i in range(1, len(b_bits)): a_powers[i] = (a_powers[i - 1] * a_powers[i - 1] )% m if b_bits[i]: total *= a_powers[i] total %= m return total % m def is_miller_rabin(x, num_tests = 3): # find e and k k = x - 1 e = 0 while k % 2 == 0: e += 1 k //= 2 tests = [False for _ in range(0, num_tests)] A = [2,3,5] for j in range(3, num_tests): A.append(random.randint(7, x - 1)) if x < 2047: num_tests = 1 elif x < 1373653: num_tests = 2 elif x < 25326001: num_tests = 3 for i in range(0, num_tests): # pick a. ak = pow_mod(A[i],k,x) if ak == 1: tests[i] = True else: for j in range(0, e): if ak == x - 1: tests[i] = True ak = (ak*ak) % x for i in range(0, num_tests): if not tests[i]: return False return True def factor(n, PL): sqrt = int(pow(n,0.5)) + 1 factor_list = [] if not PL: PL = prime_list(sqrt) for p in PL: if n % p == 0: elet = [p,0] while not n % p: n//=p elet[1] += 1 factor_list.append(elet) if n != 1: if is_miller_rabin(n): factor_list.append([n, 1]) return factor_list def longestSequence(a): PL = prime_list(200000) factors_list = [factor(a_i, PL) for a_i in a] #print(factors_list) sequence_list = [] for i in range(0, len(factors_list)): total = 1 current = 1 for j in range(0, len(factors_list[i])): power_k = len(factors_list[i]) for k in range(0, factors_list[i][power_k - 1 - j][1]): current *= factors_list[i][power_k - 1 - j][0] total += current sequence_list.append(total) return sum(sequence_list) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)