import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static Map knownSolutions = new HashMap(); static long longestSequence(long[] a) { long sum = 0; for ( long ai : a ) sum += longestSequence( ai ); return sum; } static long longestSequence( long a ) { if ( a == 1 ) return 1; if ( knownSolutions.containsKey( a ) ) return knownSolutions.get( a ); long max = Long.MIN_VALUE; for ( long length : dividers( a ) ) { // System.out.println( a+": "+length ); long nPieces = a / length; max = Math.max( max , solution( nPieces , length ) ); //max = Math.max( max , solution( length , nPieces ) ); } return max; } static long solution( long nPieces , long length ) { Long solution = knownSolutions.get( length ); if ( solution == null ) { solution = longestSequence( length ); knownSolutions.put( length , solution ); } long total = 1 + solution * nPieces; return total; } static List dividers( long a ) { List divs = new ArrayList<>(); for ( long c = 1; c <= Math.sqrt( a ) ; c++ ) { if ( a % c != 0 ) continue; if ( c != 1 ) divs.add( a / c ); divs.add( c ); } return divs; } 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(); } }