#include #include #include using namespace std; void solve() { int n; cin >> n; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); vector dp(n, 1); for (int i = 0; i < n; ++i) { int x = a[i]; for (int k = 2; (long long)x * k <= a[n-1]; ++k) { int j = x * k; auto it = lower_bound(a.begin(), a.end(), j); if (it != a.end() && *it == j) { dp[it - a.begin()] = max(dp[it - a.begin()], dp[i] + 1); } } } int longest_good_sequence_length = *max_element(dp.begin(), dp.end()); cout << longest_good_sequence_length << '\n'; } int main() { solve(); return 0; }