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