import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; 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()); String[] sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } br.close(); int[] arr = new int[300001]; for (int i = 0; i < n; i++) { List list = divList(a[i]); int max = 0; for (int j : list) { if (j < a[i]) { max = Math.max(max, arr[j]); } } arr[a[i]] = Math.max(arr[a[i]], max + 1); } int ans = 0; for (int i = 0; i < arr.length; i++) { ans = Math.max(ans, arr[i]); } System.out.println(ans); } static List divList(int n) { List list = new ArrayList<>(); int end = (int) Math.sqrt(n); for (int i = 1; i <= end; i++) { if (n % i == 0) { list.add(i); } } int i = end * end == n ? list.size() - 2 : list.size() - 1; for ( ; i > 0; i--) { list.add(n / list.get(i)); } return list; } }