import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Solution { static long longestSequence(long[] a, int n) { // Return the length of the longest possible sequence of moves. long answer = 0; for (int a_i = 0; a_i < n; a_i++) { List primeFactors = findPrimefactors(a[a_i]); primeFactors.sort(Long::compareTo); int size = primeFactors.size(); long mult = 1L; for (int i = size - 1; i >= 0; i--) { mult *= primeFactors.get(i); answer += mult; } answer++; } return answer; } private static List findPrimefactors(long num) { List factors = new ArrayList<>(); while (num % 2 == 0) { factors.add(2L); num/=2; } for(long i = 3; i<=Math.sqrt(num); i += 2L) { while (num % i == 0) { factors.add(i); num/=i; } } if (num > 2) { factors.add(num); } return factors; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] a = new long[n]; for (int a_i = 0; a_i < n; a_i++) { a[a_i] = in.nextLong(); } long result = longestSequence(a, n); System.out.println(result); in.close(); } }