#!/bin/python3 import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. result = 0 for piece in a: worklist = [piece] while worklist[0] != 1: result += len(worklist) for i in range(worklist[0]-1, 1, -1): d, m = divmod(worklist[0], i) if not m: break else: d = 1 i = worklist[0] worklist = [d] * (len(worklist) * i) else: result += piece return result if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)