#!/bin/python3 import sys def longestSequence(a): count=0 for i in a: if(i==1): count+=1 elif(i&(i-1)==0 and i%2==0): count+=i elif(i==3): count+=3 elif(i%2!=0): count+=(i+1) elif(i%2==0): #print('hell') count+=((i*2)-2) return(count) # 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)