#!/bin/python3 import sys def is_prime(n): '''check if integer n is a prime''' # make sure n is a positive integer n = abs(int(n)) # 0 and 1 are not primes if n < 2: return True # 2 is the only even prime number if n == 2: return True # all other even numbers are not primes if not n & 1: return False # range starts with 3 and only needs to go up the squareroot of n # for all odd numbers for x in range(3, int(n**0.5)+1, 2): if n % x == 0: return False return True def calculate_moves(n): if n % 2 == 0: return n + calculate_moves(n/2) else: if is_prime(n): if n == 1: return 1 return 1 + n else: diviser = 1 for i in range(3, int(n**0.5)+1): # print(i) if n % i == 0: diviser = i break #print('diviser {}'.format(diviser)) return n + calculate_moves(n / diviser) def longestSequence(a): # Return the length of the longest possible sequence of moves. sum_moves = 0 for n in a: moves_of_number = calculate_moves(n) # print('number {} moves_of_number {}'.format(n, moves_of_number)) sum_moves += moves_of_number return sum_moves if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) # result = result % (10**9+7) print(int(result))