#!/bin/python3 import sys def not_prime(num): for i in range(3, num//2+1): if num%i == 0: return i return False def longestSequence(a): # Return the length of the longest possible sequence of moves. ans = 0 for i in a: if i%2 != 0: d = not_prime(i) if d: ans += i+1 ans += d else: if i ==1: ans += 1 else: ans += (i+1) else: ans += i while i!=1: i = i//2 ans += i return ans if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)