import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long maxValue=-1; Map moveByLength = new HashMap(); moveByLength.put(new Long(1),new Long(1)); long totalMaxMoves=0; for(int i=0;i moveByLength) { if(num<=0) return 0; if(moveByLength.containsKey(num)) return moveByLength.get(num); long maxMove=num; for(long i=2;i<=Math.sqrt(num);i++) { if(num%i==0) { long factor1=num/i; long factor2=i; long currMaxMove1= factor1 * findMaxMove(factor2,moveByLength); long currMaxMove2= factor2 * findMaxMove(factor1,moveByLength); maxMove = maxMove > currMaxMove1 ? maxMove : currMaxMove1; maxMove = maxMove > currMaxMove2 ? maxMove : currMaxMove2; } } moveByLength.put(num,1+maxMove); return 1+maxMove; } 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(); } }