#include <bits/stdc++.h>
//file stream
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>
#include <set>

using namespace std;
#define output freopen("output.txt","w",stdout)
#define input freopen("input.txt","r",stdin)
#define inputfile(x) freopen(x,"r",stdin)
#define outpufile(x) freopen(x,"w",stdout)
//functions
#define pb(x)  push_back(x)
#define pf  printf
#define sc scanf
#define maxe max_element
#define mine min_element
#define lb  lower_bound // first element which does not compare less than
#define ub  upper_bound //first element which compares greater than
#define bs  binary_search


#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
// pair
#define xx first
#define yy second
#define mp(x,y) make_pair(x,y)

///IO MACRO
//inputs 1 var
#define si1(n) sc("%d",&n)
#define sl1(n) sc("%I64d",&n)
#define sd1(n) sc("%lf",&n)
#define ss1(n) sc("%s",n)
//inputs 2 var
#define si2(n,m) sc("%d %d",&n,&m)
#define sl2(n,m) sc("%I64d %I64d",&n,&m)
#define sd2(n,m) sc("%lf %lf",&n,&m)
//inputs 3 var
#define si3(n,m,l) sc("%d %d %d",&n,&m,&l)
#define sl3(n,m,l) sc("%I64d %I64d %I64d",&n,&m,&l)
#define sd3(n,m,l) sc("%lf %lf %lf",&n,&m,&l)

//output 1 var
#define pi1(n) pf("%d",n)
#define pl1(n) pf("%I64d",n)
#define pd1(n,pre) pf("%.*f",pre,n)
#define ps1(n) pf("%s",n)
//output 2 var
#define pi2(n,m) pf("%d %d",n,m)
#define pl2(n,m) pf("%I64d %I64d",n,m)
#define pd2(n,m,pre) pf("%.*f %.*f",pre,n,pre,m)
//inputs 3 var less important
#define pi3(n,m,l) pf("%d %d %d",n,m,l)
#define pl3(n,m,l) pf("%I64d %I64d %I64d",n,m,l)
//output misc
#define nln putchar(10)
#define sps putchar(' ')
#define pch(c) putchar(c)
#define tcsp(i) pf("Case %d: ",++i)
#define tcnl(i) pf("Case %d:\n",++i)
#define dbg()   pf("-----------")

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sc1(n) cin>>n
#define sc2(n,m) cin>>n>>m
#define sc3(n,m,k) cin>>n>>m>>k
#define sc4(n,m,k,l) cin>>n>>m>>k>>l

#define pr1(n) cout<<n
#define pr2(n,m) cout<<n<<" "<<m
#define pr3(n,m,k) cout<<n<<" "<<m<<" "<<k
#define pr4(n,m,k,l) cin<<n<<" "<<m<<" "<<k<<" "<<l
#define NL cout<<endl
#define setPre(x) setprecision(x)
#define fixP cout<<fixed
///IO MACRO end



//loop
#define fr0(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define FR(i,b,e) for(i=b;i<=e;i++)
#define FRR(i,e,b) for(i=e;i>=b;i--)

//to compile in codeblocks , c++11 flag must be off
//additional, only work if compiled with gcc compiler
#define frf(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define frr(c, it) for(typeof((c).rbegin()) it = (c).rbegin(); it != (c).rend(); it++)
//memory reset
#define set0(x) memset(x,0,sizeof x)
#define set(x,v) memset(x,v,sizeof x)
#define setn1(x) memset(x,-1,sizeof x)
#define setinf(x) memset(x,125,sizeof x)
//misc
#define SZ(v)   ((int) (v).size())
#define all(v)  (v).begin(), (v).end()
//bit operation single variable
#define On(x,i)  (x|=(1<<(i)))
#define Off(x,i) (x&= ~(1<<(i)))
#define isOn(x,i) (x&(1<<(i)))
#define Toggle(x,i) (x^=(1<<(i)))
#define tmod(x,i)  (x&(~(-1<<i)))
//constant
const double EPS = 1e-9;
const int SIZE=1e6;
//BIT
int __bit[SIZE+100],_n,_lg;
void __inc(int i,int v){for(;i<=_n;i+=(i&-i))__bit[i]+=v;}
int __sum(int i){int s=0;for(;i;i-=(i&-i))s+=__bit[i];return s;}
int __select(int k){int p,i,h=0;for(i=_lg;i>-1;i--){p=1<<i;if(p+h>_n)continue;if(__bit[p+h]<k)h+=p,k-=__bit[h];}return h+1;}
//BIG MOD / mod inverse

//egcd / mod inverse


//direction array

//data type
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<pii ,pii > ppii;
typedef set<int> si;
typedef set<ll> sl;
typedef map<int,int> mii;
typedef map<ll,int> mli;
typedef map<string,int> msi;






int i,j,k,m,n,a,b,c,tc,o,ans,q,x,y;

char s[100099],com[109];

multiset<int> st;
si stt;

int main()
{

    si1(n);

    fr0(i,n)
    {
        si1(a);
        st.insert(a);st.insert(a-1);st.insert(a+1);
        stt.insert(a);stt.insert(a-1);stt.insert(a+1);

    }

    m=0;

    for(int c:stt)m=max(m,(int)st.count(c));

    pi1(m);nln;



    return 0;
}



Measured memory_bytes: 18816