#!/bin/python3 import sys import math def getfactors(n): arr = [] for i in range(2,int(n**0.5)+1): if not n%i: arr.extend([i,n//i]) return arr def smallestDividingNumber(n): for i in range(2,n+1): if n%i: return i return n def calculateLongestSequence(stick,lookup): if stick in lookup: return lookup[stick] else: if stick == 1: lookup[1] = stick return 1 else: factors = getfactors(stick) if len(factors) == 0: lookup[stick] = (stick +1) return lookup[stick] else: moves = [] for f in factors: lookup[stick//f] = calculateLongestSequence(stick//f,lookup) lookup[stick] = f*lookup[stick//f] + 1 moves.append(lookup[stick]) return max(moves) return 0 def longestSequence(sticks): # Return the length of the longest possible sequence of moves. totalMoves = sum(calculateLongestSequence(stick,{}) for stick in sticks) return totalMoves if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)