import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Solution { static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. HashMap store=new HashMap<>(); long x=1,y=1; store.put(x,y); long ans = 0; for(int i=0;i store){ if(store.containsKey(value)) return store.get(value); else{ long ans=value+1; for(long i=2;i*i<=value;i++){ if(value%i==0){ long x=value/i; long ans1=i*give_ans(x,store)+1; if(ans1>ans) ans=ans1; ans1=x*give_ans(i,store)+1; if(ans1>ans) ans=ans1; } } //System.out.println("storing "+ans+" for "+value); store.put(value,ans); return ans; } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void main(String[] args) { FastReader in = new FastReader(); 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); } }