#include #include #include int main() { static constexpr int ALim = 300001; int n; std::cin >> n; std::vector> rev(ALim); std::vector dp(ALim, -1); for (int i = 0; i != n; ++i) { int a; std::cin >> a; rev[a].push_back(i); dp[a] = i; } int len = 0; while ( std::any_of(dp.cbegin(), dp.cend(), [](const int x) { return x > -1; })) { ++len; for (int i = 1; i != ALim; ++i) { int max = -1; for (int j = i + i; j < ALim; j += i) { max = std::max(max, dp[j]); } int j = 0; const int size = rev[i].size(); while (j != size && rev[i][j] < max) { ++j; } if (j == 0) { dp[i] = -1; } else { dp[i] = rev[i][j - 1]; } } } std::cout << len << std::endl; }