#!/bin/python3 import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. ct=0 for i in a: if(i>1): c=1 else: c=0 j=i-1 k=i while j>1: if(k%j == 0): c+=j k=j j-=1 c+=i ct+=c return ct if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)