using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] length = new int[500000]; for (int i = 0; i < n; i++) { var res = 0; for (int j = 1; j * j <= a[i]; j++) { if (a[i] % j != 0) continue; if (j != 1) res = Max(res, length[a[i] / j]); res = Max(res, length[j]); } length[a[i]] = res + 1; } Console.WriteLine(length.Max()); } }