#!/bin/python3 import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. moves=0 for n in a: current = 1 s = [] even_flag = 0 odd_flag = 0 for i in range(1, int(n**0.5) + 1): if (n % i == 0): if(i%2 == 0): even_flag = 1 else: odd_flag = 1 s.append(i) s.append(n//i) k = set(s) s = list(k) if(even_flag > 0 and odd_flag > 0): for i in s[1:]: if(i%2!=0): break while(True): m=i current+=i i=i*2 if(i==n): current+=i break elif(i>=(n//m)): current+=i+n break else: current=sum(s) moves+=current return moves if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)