import java.math.BigInteger; import java.util.*; public class Watermelon { static boolean[] primer = new boolean[1000050]; static int[] array=new int[1000000]; 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(); } static long longestSequence(long[] a) { int t=a.length; int ans=0; for(int b=0;b list = new ArrayList<>(); Arrays.fill(array, Integer.MIN_VALUE); sieveOfEratosthenes(); for (int i = 1; i <= k + 1; i++) { if (n % i == 0) { if (n / i == i) list.add(i); else { list.add(n / i); list.add(i); } } } //System.out.print(divisors(2)); int x=(recurs(list, n, n, list.size() == 2 || n==1)); // System.out.println("x ------------------>"+x); ans+=x; // display(array); } return ans; } static int recurs(ArrayList list,int n,int k,boolean prime) { //System.out.println(list+" "+n+" "+k); if(n==1) { //System.out.println(n+"Hey"); if(prime) return k; else return 0; } if(array[n]!=Integer.MIN_VALUE) { // System.out.println(array[n]+"Hey1"); return array[n]; } for(int i=0;i divisors(int n) { int k=(int)Math.sqrt(n); ArrayList list = new ArrayList<>(); for (int i = 1; i <= k + 1; i++) { if (n % i == 0) { if (n / i == i) list.add(i); else { list.add(n / i); list.add(i); } } } return list; } static void sieveOfEratosthenes() { int n = 1000001; for (int i = 0; i < n; i++) primer[i] = true; for (int p = 2; p * p <= n; p++) { if (primer[p] == true) { for (int i = p * 2; i <= n; i += p) primer[i] = false; } } } static void recurs(int[][] arr, int x, int y, int value, String[][] sarr, String s) { // System.out.println("Heyt"); try { if (value < arr[x][y]) { arr[x][y] = value; sarr[x][y] = s; } else return; } catch (Exception e) { // System.out.println("Exception"); return; } //display(arr); //System.out.print("\n"); recurs(arr, x - 2, y - 1, value + 1, sarr, sarr[x][y] + " UL"); recurs(arr, x - 2, y + 1, value + 1, sarr, sarr[x][y] + " UR"); recurs(arr, x, y + 2, value + 1, sarr, sarr[x][y] + " R"); recurs(arr, x + 2, y + 1, value + 1, sarr, sarr[x][y] + " LR"); recurs(arr, x + 2, y - 1, value + 1, sarr, sarr[x][y] + " LL"); recurs(arr, x, y - 2, value + 1, sarr, sarr[x][y] + " L"); } /** * Function to update tree **/ static void build(long[] tree, int[] arr, int node, int start, int end) { if (start == end) { tree[node] = arr[start]; System.out.println("node " + node + " start " + start + " end " + end + " tree[node] " + tree[node]); return; } int mid = (start + end) >> 1; build(tree, arr, 2 * node, start, mid); build(tree, arr, 2 * node + 1, mid + 1, end); tree[node] = Math.min(tree[2 * node], tree[2 * node + 1]); //System.out.println(" start " + start + " end " + end + " tree[node]" + tree[node]); } private static void update(long[] tree, int node, int pos, long val, int start, int end) { //System.out.println("start " + start + " end " + end); if (start == end) { tree[node] = val; // System.out.println(tree[start]); return; } else { int mid = (start + end) >> 1; if (start <= pos && pos <= mid) { update(tree, 2 * node, pos, val, start, mid); } else { update(tree, 2 * node + 1, pos, val, mid + 1, end); } tree[node] = Math.min(tree[node * 2], tree[node * 2 + 1]); } } /** * Function to query **/ private static long query(long[] tree, int node, long l, long r, long start, long end) { if (start > r || end < l) return Integer.MAX_VALUE; if (start >= l && end <= r) { return tree[node]; } long mid = (start + end) >> 1; long p1 = query(tree, node * 2, l, r, start, mid); long p2 = query(tree, node * 2 + 1, l, r, mid + 1, end); // System.out.println(" start " + start + " end " + end + " tree[node]" + tree[node]); return Math.min(p1, p2); } static void display(int[][] dp) { for (int i = 0; i < dp.length; i++) { for (int j = 0; j < dp[i].length; j++) { if (dp[i][j] == Integer.MAX_VALUE) System.out.print("I\t"); else System.out.print(dp[i][j] + "\t"); } System.out.println(); } } static void display(String[][] dp) { for (int i = 0; i < dp.length; i++) { for (int j = 0; j < dp[i].length; j++) { System.out.print(dp[i][j] + "\t\t\t"); } System.out.println(); } } static void display(int[] ans) { for (int i = 0; i < ans.length; i++) System.out.print(ans[i] + " "); System.out.println(); } static void display(long[] ans, int n) { for (int i = 0; i < n; i++) System.out.print(ans[i] + " "); System.out.println(); } static int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } // Function to find gcd of array of // numbers static int findGCD(Integer arr[], int n) { int result = arr[0]; for (int i = 1; i < n; i++) result = gcd(arr[i], result); return result; } }