import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static long[] precomp; public static List primes; static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long ret = 0; for (int i=0;i top) { bp = true; break; } if (i%p == 0) break; } if (bp) primes.add(i); } } public static long precomp(long a){ if (a < 1000001 && precomp[(int)a] > 0) return precomp[(int)a]; long ret = 0; int ps = primes.size(); for(int k= ps-1;k>=0;k--){ if ( a % primes.get(k) == 0) return 1 + primes.get(k)*precomp(a/primes.get(k)); } ret = 1 + a*precomp[1]; return ret; } public static void main(String[] args) { precomp = new long[1000001]; primes = new ArrayList(); computePrime(1000000); precomp[1] = 1; precomp(1000001); 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); System.out.println(result); in.close(); } }