import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] map = new int[300001]; int ans = 1; String[] line = br.readLine().split(" ", n); for (int i = 0; i < n; i++) { int max = 0; int x = Integer.parseInt(line[i]); if (x != 1) { max = map[1]; } for (int j = 2; j <= Math.sqrt(x); j++) { if (x % j == 0) { max = Math.max(max, map[j]); max = Math.max(max, map[x / j]); } } map[x] = max + 1; ans = Math.max(ans, max + 1); } System.out.println(ans); } }