#!/bin/python3 import sys seq = [0,1,3,4,7,6] def moves(a): if (a m): m = cm if (m!=0): seq.append(m+1) return (m+1) else: seq.append(a+1) return (a+1) if(a > len(seq)): x = (moves(a-1)) m = 0 for i in range(2, int(a**0.5) + 1, 1): if (a%i==0): x = i*seq[a//i] y = a//i*seq[i] cm = max(x,y) if (cm > m): m = cm if (m!=0): seq.append(m+1) return (m+1) else: seq.append(a+1) return (a+1) def longestSequence(a): # Return the length of the longest possible sequence of moves. suma = 0 for b in a: suma += moves(b) return suma if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)