#!/bin/python3 import sys from math import log def maxPowerOfTwo(n): binSize = int(log(n, 2)) currentMax = 0 for j in range(binSize + 1): if n % int(2 ** j) == 0: currentMax = j return (int(2 ** (currentMax + 1)) - 1, int(n / (2 ** currentMax))) def longestSequence(a): sum = 0 for n in a: if n == 1: sum += 1 else: maxN = maxPowerOfTwo(n) sum += maxN[0] * maxN[1] + 1 return sum if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)