#!/bin/python import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. result = [] for each_elem in a: if each_elem % 2 == 0: if each_elem % 3 == 0: result.append(2 * (each_elem) - 2 ) else: result.append(2 * (each_elem) - 1) elif each_elem % 2 == 1: if each_elem == 1: result.append(1) else: result.append(1 + each_elem) return reduce(lambda x,y: x+y, result) if __name__ == "__main__": n = int(raw_input().strip()) a = map(int, raw_input().strip().split(' ')) result = longestSequence(a) print result