/// Angry Cows (Gold)
/// Author: Qwerty
#include<bits/stdc++.h>
using namespace std;
int n;
int a[10000];
int expIndex(int hay[], int start, bool left){
int last = start;
int r = 1;
int dir;
if (left)
dir = -1;
else
dir = 1;
if (left){
while (last > 0 && last - 1 < n - 1){
int next = last;
while ((next + dir >= 0 && next + dir < n) && abs(hay[next + dir] - hay[last]) <= r){
next += dir;
}
if (next == last)
break;
last = next;
r++;
}
}
else {
while (last < n - 1){
int next = last;
while ((next + dir >= 0 && next + dir < n) && abs(hay[next + dir] - hay[last]) <= r){
next += dir;
}
if (next == last)
break;
last = next;
r++;
}
}
return last;
}
int main(){
//freopen("angry.in","r",stdin);
//freopen("angry.out","w",stdout);
int ans=0;
cin>>n;
for (int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
for (int i = 0; i < n; i++){
int left=expIndex(a,i,true);
int right=expIndex(a,i,false);
int explode=right-left+1;
if (explode>ans)
ans=explode;
}
cout<<ans;
}
Ly8vIEFuZ3J5IENvd3MgKEdvbGQpCi8vLyBBdXRob3I6IFF3ZXJ0eQojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbjsKaW50IGFbMTAwMDBdOwppbnQgZXhwSW5kZXgoaW50IGhheVtdLCBpbnQgc3RhcnQsIGJvb2wgbGVmdCl7CiAgICBpbnQgbGFzdCA9IHN0YXJ0OwogICAgaW50IHIgPSAxOwogICAgaW50IGRpcjsKICAgIGlmIChsZWZ0KQogICAgICAgIGRpciA9IC0xOwogICAgZWxzZQogICAgICAgIGRpciA9IDE7CiAgICBpZiAobGVmdCl7CiAgICAgICAgd2hpbGUgKGxhc3QgPiAwICYmIGxhc3QgLSAxIDwgbiAtIDEpewogICAgICAgICAgICBpbnQgbmV4dCA9IGxhc3Q7CiAgICAgICAgICAgIHdoaWxlICgobmV4dCArIGRpciA+PSAwICYmIG5leHQgKyBkaXIgPCBuKSAmJiBhYnMoaGF5W25leHQgKyBkaXJdIC0gaGF5W2xhc3RdKSA8PSByKXsKICAgICAgICAgICAgICAgIG5leHQgKz0gZGlyOwogICAgICAgICAgfQogICAgICAgICAgICBpZiAobmV4dCA9PSBsYXN0KQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGxhc3QgPSBuZXh0OwogICAgICAgICAgICByKys7CiAgICAgICAgfQogICAgfQogICAgZWxzZSB7CiAgICAgICAgd2hpbGUgKGxhc3QgPCBuIC0gMSl7CiAgICAgICAgICAgIGludCBuZXh0ID0gbGFzdDsKICAgICAgICAgICAgd2hpbGUgKChuZXh0ICsgZGlyID49IDAgJiYgbmV4dCArIGRpciA8IG4pICYmIGFicyhoYXlbbmV4dCArIGRpcl0gLSBoYXlbbGFzdF0pIDw9IHIpewogICAgICAgICAgICAgICAgbmV4dCArPSBkaXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKG5leHQgPT0gbGFzdCkKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBsYXN0ID0gbmV4dDsKICAgICAgICAgICAgcisrOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBsYXN0Owp9CmludCBtYWluKCl7CiAgICAvL2ZyZW9wZW4oImFuZ3J5LmluIiwiciIsc3RkaW4pOwogICAgLy9mcmVvcGVuKCJhbmdyeS5vdXQiLCJ3IixzdGRvdXQpOwogICAgaW50IGFucz0wOwogICAgY2luPj5uOwogICAgZm9yIChpbnQgaT0wO2k8bjtpKyspewogICAgICAgICBjaW4+PmFbaV07CiAgICB9CiAgICBzb3J0KGEsYStuKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgICBpbnQgbGVmdD1leHBJbmRleChhLGksdHJ1ZSk7CiAgICAgICAgaW50IHJpZ2h0PWV4cEluZGV4KGEsaSxmYWxzZSk7CiAgICAgICAgaW50IGV4cGxvZGU9cmlnaHQtbGVmdCsxOwogICAgICAgIGlmIChleHBsb2RlPmFucykKICAgICAgICAgICAgYW5zPWV4cGxvZGU7CiAgICB9CiAgICBjb3V0PDxhbnM7Cn0K