# -*- coding: utf-8 -*- """ Created on Fri Dec 15 22:45:43 2017 @author: MOON """ #!/bin/python3 import sys dictionary = {} dictionary[1] = 1 def longestSequence(a): # Return the length of the longest possible sequence of moves. moves = 0 for stick in a: stick = int(stick) moves += longestSequences(stick) return moves def factorsStick(stick): temp = [] #temp = int(stick) # b = int(stick/2) if(stick == 1): return [1] for i in range(1, int(stick/2)+1 ): if stick % i == 0: if(i not in temp): temp.append(i) if(int(stick/i) not in temp): temp.append(int(stick/i)) temp.remove(stick) return temp def longestSequences(stick): factors = factorsStick(stick) step = [] if(stick == 1): return 1 else: for factor in factors: if(factor in dictionary): step.append(dictionary[factor]) else: moves = longestSequences(factor) dictionary[factor] = moves step.append(moves) i = 0 # print(step) steps = [] for factor in factors: steps.append(1 + step[i]* int(stick/factor)) i+=1 #print( steps) maxSteps = max(steps) #index = step.index(maxSteps) #factor = factors[index] return maxSteps #1+ maxSteps * int(stick/factor) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)