import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { HashMap map=new HashMap<>(); map.put(1L,1L); long res=0; for(int i=0;i map,long parts){ if(a==1) return parts; long max=0; for(int i=1;i<=a/2;i++){ if(a%i==0){ max=Math.max(max,(parts*calc(i,map,a/i))+parts); // System.out.println(a+" "+i+" "+max+" "+parts); } } return max; } 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); System.out.println(result); in.close(); } }