#!/bin/python def val_to_string(divider, size): return str(divider) + '_' + str(size) def val_from_string(position): return map(int, position.split('_')) def longestSequenceForStick(stick): # a FIFO open_set open_set = list() totalSize = stick max_cost = 0 cost = {} nbPieces = totalSize / 2 while nbPieces: if totalSize % nbPieces == 0: key = val_to_string(nbPieces, totalSize / nbPieces) cost[key] = 1 open_set.append(key) nbPieces -= 1 while open_set: old_key = open_set.pop(0) old_cost = cost[old_key] size, nb = val_from_string(old_key) if size == 1: new_cost = old_cost + nb if new_cost > max_cost: max_cost = new_cost continue nbPieces = size / 2 or 1 while nbPieces: if size % nbPieces == 0: key = val_to_string(nbPieces, (size / nbPieces) * nb) new_cost = old_cost + nb if new_cost > old_cost: cost[key] = new_cost if key not in open_set and new_cost <= max_cost - 10: open_set.append(key) if new_cost > max_cost: max_cost = new_cost nbPieces -= 1 return max_cost or 1 def longestSequence(a): # Return the length of the longest possible sequence of moves. sum = 0 for stick in a: sum += longestSequenceForStick(stick) return sum if __name__ == "__main__": n = int(raw_input().strip()) a = map(long, raw_input().strip().split(' ')) result = longestSequence(a) print result