#include <bits/stdc++.h>
using namespace std;
const int N=1e5+9;
int cnt[N];
inline int read()
 {
    int s = 1, a = 0; char ch = getchar();
    while (ch<'0'||ch>'9') {if(ch =='-') s = -1; ch = getchar();}
    while (ch>='0'&&ch<='9') {a=a*10+ch-'0';ch=getchar();}
    return s*a;
}
int main() {
    int n=read();
    for (int i=1;i<=n;i++) {
        int ai= read();
        cnt[ai]++,cnt[ai+1]++,cnt[ai-1]++;
    }
    int res=0;
    for (int i=0;i<=1e5;i++) res=max(res,cnt[i]);
    return 0*printf("%d\n",res);
}