#!/bin/python3 import sys import math def longestSequence(a, moves = False): # Create list of moves moves = [0 for i in range(max(a))] # Mark in the list the values to be found for stick in a: moves[stick - 1] = -1 # Value for size 1 must be 1 moves[0] = 1 moves[1] = 3 # Start looking for required values while (-1 in moves): stick = moves.index(-1) + 1 max_moves = stick + 1 i = 2 while (i <= math.ceil(math.sqrt(stick))) and max_moves > 0: if max_moves < 0: continue if (stick % i == 0): j = int(stick / i) if (moves[i - 1] > 0 and moves[j - 1] > 0): max_moves = max(max_moves, (moves[i - 1] * j) + 1, (moves[j - 1] * i) + 1) else: if (moves[i - 1] == 0): moves[i - 1] = -1 if (moves[j - 1] == 0): moves[j - 1] = -1 max_moves = -1 i += 1 moves[stick - 1] = max_moves total = 0 for i in a: total += moves[i - 1] return total if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)