import java.util.*; public class Main { static HashSet exists = new HashSet<>(); static TreeMap dp = new TreeMap<>(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < n; i++) { exists.add(sc.nextInt()); } int max = 0; for (int x : exists) { max = Math.max(max, dfw(x)); } System.out.println(max); } static int dfw(int x) { if (dp.containsKey(x)) { return dp.get(x); } if (!exists.contains(x)) { dp.put(x, 0); return 0; } if (x == 1) { dp.put(x, 1); return 1; } int max = dfw(1); for (int i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { max = Math.max(max, dfw(i)); max = Math.max(max, dfw(x / i)); } } dp.put(x, max + 1); return max + 1; } }