import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; public class Main { static void solver() { int n = ni(); int[] x = new int[n]; for (int i = 0; i < n; i++) { x[i] = ni(); } Arrays.sort(x); ArrayList primeList = primeList((int) Math.sqrt(x[x.length - 1])); int[] dp = new int[x[x.length - 1] + 1]; int ans = 0; for (int i = 0; i < n; i++) { ArrayList div = enum_div(primeFactorF(primeList, x[i])); long max = 0; for (long d : div) { if (d == x[i]) continue; if (dp[(int) d] != 0) { max = Math.max(max, dp[(int) d]); } } dp[x[i]] = (int) (max + 1); ans = Math.max(ans, dp[x[i]]); } out.println(ans); } static InputStream is; static PrintWriter out; static String INPUT = ""; public static void main(String[] args) throws Exception { is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); long cur = System.currentTimeMillis(); out = new PrintWriter(System.out); solver(); // out.println(System.currentTimeMillis() - cur + " ms"); out.flush(); } static long nl() { try { long num = 0; boolean minus = false; while ((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-')) ; if (num == '-') { num = 0; minus = true; } else { num -= '0'; } while (true) { int b = is.read(); if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } } } catch (IOException e) { } return -1; } static char nc() { try { int b = skip(); if (b == -1) return 0; return (char) b; } catch (IOException e) { } return 0; } static double nd() { try { return Double.parseDouble(ns()); } catch (Exception e) { } return 0; } static String ns() { try { int b = skip(); StringBuilder sb = new StringBuilder(); if (b == -1) return ""; sb.append((char) b); while (true) { b = is.read(); if (b == -1) return sb.toString(); if (b <= ' ') return sb.toString(); sb.append((char) b); } } catch (IOException e) { } return ""; } public static char[] ns(int n) { char[] buf = new char[n]; try { int b = skip(), p = 0; if (b == -1) return null; buf[p++] = (char) b; while (p < n) { b = is.read(); if (b == -1 || b <= ' ') break; buf[p++] = (char) b; } return Arrays.copyOf(buf, p); } catch (IOException e) { } return null; } public static byte[] nse(int n) { byte[] buf = new byte[n]; try { int b = skip(); if (b == -1) return null; is.read(buf); return buf; } catch (IOException e) { } return null; } static int skip() throws IOException { int b; while ((b = is.read()) != -1 && !(b >= 33 && b <= 126)) ; return b; } static boolean eof() { try { is.mark(1000); int b = skip(); is.reset(); return b == -1; } catch (IOException e) { return true; } } static boolean[] isPrimeArray(int max) { boolean[] isPrime = new boolean[max + 1]; Arrays.fill(isPrime, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i * i <= max; i++) { if (isPrime[i]) { for (int j = 2; j * i <= max; j++) { isPrime[j * i] = false; } } } return isPrime; } static ArrayList primeList(int max) { boolean[] isPrime = isPrimeArray(max); ArrayList primeList = new ArrayList(); for (int i = 2; i <= max; i++) { if (isPrime[i]) { primeList.add(i); } } return primeList; } static int ni() { try { int num = 0; boolean minus = false; while ((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-')) ; if (num == '-') { num = 0; minus = true; } else { num -= '0'; } while (true) { int b = is.read(); if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } } } catch (IOException e) { } return -1; } static ArrayList primeFactorF(ArrayList primeList, long num) { ArrayList ret = new ArrayList(); for (int p : primeList) { int exp = 0; while (num % p == 0) { num /= p; exp++; } if (exp > 0) ret.add(new Factor(p, exp)); } if (num > 1) ret.add(new Factor(num, 1)); return ret; } static ArrayList enum_div(ArrayList f) { ArrayList ret = new ArrayList(); ret.add(1L); for (int i = 0; i < f.size(); i++) { long a = 1; int n = ret.size(); for (int j = 0; j < f.get(i).exp; j++) { a *= f.get(i).base; for (int k = 0; k < n; k++) { ret.add(ret.get(k) * a); } } } return ret; } static class Factor { long base, exp; Factor(long base, long exp) { this.base = base; this.exp = exp; } } }