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