#!/bin/python import sys def longestSequence(a): moves = 0 def log(a): res = 0 while a<1: res -= 1 a *= 2 while a>=2: res += 1 a /= 2 return res def gcd(a, b): while b: a, b = b, a%b return a for chocolate in range (0, len(a)): if a[chocolate] % 2 == 1: if a[chocolate] == 1: moves += 1 else: moves += (a[chocolate] + 1) else: this_gcd = 0 for c in range (0, log(a[chocolate])): this_gcd = gcd(a[chocolate], pow(2, log(a[chocolate]))) if this_gcd > 1: groupSize = this_gcd groupsOf = a[chocolate]/groupSize else: break moves += 1 for i in range (0, log(groupSize)+1): moves += groupsOf groupsOf = groupsOf*2 return moves # Return the length of the longest possible sequence of moves. if __name__ == "__main__": n = int(raw_input().strip()) a = map(long, raw_input().strip().split(' ')) result = longestSequence(a) print result