#include<iostream> #include<random> #define maxn 2000010 #define ll long long usingnamespacestd;
constint N = 30;
int pri[maxn], cnt; bool isp[maxn]; voidinit_isp(int n){ for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) break; } } }
default_random_engine e(20011203);
int n; ll a[maxn];
intsolve(ll d, ll v){ int res = 0; for (int i = 1; i <= n; ++i) res += a[i] % d == v; return res; }
voidwork(){ cin >> n; int ans = 1; uniform_int_distribution<int> Rand(1, n); for (int i = 1; i <= n; ++i) cin >> a[i]; for (int o = 1; o <= N; ++o) { int x, y; do { x = Rand(e); y = Rand(e); } while (x == y); ll d = abs(a[x] - a[y]); for (int i = 1; i <= cnt && 1ll * pri[i] * pri[i] <= d; ++i) { if (d % pri[i] == 0) ans = max(ans, solve(pri[i], a[x] % pri[i])); while (d % pri[i] == 0) d /= pri[i]; } if (d > 1) ans = max(ans, solve(d, a[x] % d)); } cout << ans << "\n"; }