You are given an integer sequence of length N, a_1,a_2,...,a_N.
For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.
After these operations, you select an integer X and count the number of i such that a_i=X.
Maximize this count by making optimal choices.

-----Constraints-----
 - 1≤N≤10^5
 - 0≤a_i<10^5 (1≤i≤N)
 - a_i is an integer.

-----Input-----
The input is given from Standard Input in the following format:
N
a_1 a_2 .. a_N

-----Output-----
Print the maximum possible number of i such that a_i=X.

-----Sample Input-----
7
3 1 4 1 5 9 2

-----Sample Output-----
4

For example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.
[{"code": "# -1 0 1\u3092\u8db3\u3057\u305f\u3082\u306e\u306e\u3046\u3061\u6700\u5927\u5024\u3092\u6570\u3048\u308b\nn = int(input())\na = list(map(int, input().split()))\n# ai=0\u306e\u5834\u5408\u3082\u3042\u308b\u306e\u3067-1\u304c\u3042\u308a\u3048\u308b\u3053\u3068\u306b\u6ce8\u610f \u9069\u5f53\u306ba[0]\u3092-1\u306e\u6570\u3068\u3059\u308b\nd = [0] * (10**5 + 10)\nfor av in a:\n    for x in [-1, 0, 1]:\n        # \u524d\u8ff0\u306e\u901a\u308aa[0]\u3092-1\u306e\u6570\u3068\u3059\u308b\n        d[av + x + 1] += 1\nprint(max(d))", "passed": true, "time": 0.19, "memory": 14108.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\n\nans = 0\n\ncnt = [0]*100001\n\nfor i in a:\n    cnt[i] += 1\n\nfor i in range(len(cnt)-2):\n    ans = max(ans,cnt[i]+cnt[i+1]+cnt[i+2])\n\nprint(ans)\n", "passed": true, "time": 0.24, "memory": 14096.0, "status": "done"}, {"code": "from collections import defaultdict\nd = defaultdict(int)\nN = int(input())\nN_List = list(map(int,input().split()))\n\nfor i in range(N):\n    CN = N_List[i]\n    for k in range(-1,2,1):\n        d[CN + k] += 1\n        \nprint(max(d.values()))", "passed": true, "time": 2.69, "memory": 14164.0, "status": "done"}, {"code": "import sys, math\nfrom functools import lru_cache\nfrom itertools import accumulate\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n    return sys.stdin.readline()[:-1]\n\ndef mi():\n    return list(map(int, input().split()))\n\ndef ii():\n    return int(input())\n\ndef i2(n):\n    tmp = [list(mi()) for i in range(n)]\n    return [list(i) for i in zip(*tmp)]\n\nN = ii()\na = list(mi())\n\nl = [0]*(max(a)+5)\n\nfor i in range(N):\n    l[a[i]] += 1\n    l[a[i]+3] -= 1\n\nacc = list(accumulate(l))\n\nprint((max(acc)))\n\n\n", "passed": true, "time": 0.24, "memory": 15276.0, "status": "done"}, {"code": "import collections\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(lambda x: x-1, a))\nc = list(map(lambda y: y+1, a))\nd = a+b+c\n\ne = collections.Counter(d)\nprint(max(e.values()))", "passed": true, "time": 2.12, "memory": 14076.0, "status": "done"}, {"code": "n = int(input())\nal = list(map(int, input().split()))\n\nans = [0]*(10**5+2)\n\nfor a in al:\n    ans[a] += 1\n    ans[a-1] += 1\n    ans[a+1] += 1\n\nprint(max(ans))", "passed": true, "time": 0.14, "memory": 14248.0, "status": "done"}, {"code": "n = int(input())\na = [int(x) for x in input().split()]\na.sort()\n\np = [0] * (max(a) + 5)\n\nfor i in range(n):\n  p[a[i]+1] += 1\n  \nres = 0\nfor i in range(min(a),max(a)+1):\n  res = max(res, p[i] + p[i+1] + p[i+2])\n\nprint(res)", "passed": true, "time": 0.25, "memory": 14196.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nnum_list = [0] * 10 ** 5\nfor i in range(n):\n    num_list[a[i]] += 1\n\nres = 0\nfor i in range(1, 10 ** 5 - 1):\n    res = max(res, num_list[i - 1] + num_list[i] + num_list[i + 1])\n\nprint(res)\n", "passed": true, "time": 2.71, "memory": 14168.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nc=[0]*(10**5+3)\nfor i in range(n):\n  c[a[i]]+=1\n  c[a[i]-1]+=1\n  c[a[i]+1]+=1\nprint(max(c))", "passed": true, "time": 0.16, "memory": 14640.0, "status": "done"}, {"code": "n = int(input())\nal = list(map(int, input().split()))\nal.sort()\nal.append(-1)\ncnt = 1\nbl = []\nfor i in range(n):\n    if al[i] == al[i+1]:\n        cnt += 1\n    else:\n        bl.append([al[i], cnt])\n        cnt = 1\ntmp = 0\nans = 0\nfor j in range(len(bl)):\n    tmp = bl[j][1]\n    if bl[j-1][0] + 1 == bl[j][0]:\n        tmp += bl[j-1][1]\n    if j!=len(bl)-1 and bl[j][0] == bl[j+1][0] - 1:\n        tmp += bl[j+1][1]\n\n    if tmp > ans:\n        ans = tmp\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14160.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\n\ncnt = [0] * (10**5 + 1)\n\nfor i in a:\n    cnt[i] += 1\n\nx_cnt = [0] * (10**5 +1)\nfor x in range(1, 10**5):\n    tmp = cnt[x-1] + cnt[x] + cnt[x+1]\n    x_cnt[x] = tmp\n\nprint(max(x_cnt))", "passed": true, "time": 0.32, "memory": 14928.0, "status": "done"}, {"code": "from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\nB = []\nfor a in A:\n    B.append(a-1)\n    B.append(a)\n    B.append(a+1)\nC = Counter(B)\n\nprint(C.most_common()[0][1])", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "import collections\n\nn = int(input())\na = list(map(int, input().split()))\n\nlower_a = list(map(lambda x: x - 1, a))\nupper_a = list(map(lambda x: x + 1, a))\nextended_a = collections.Counter(a + lower_a + upper_a)\n\nprint(extended_a.most_common()[0][1])", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "input();B=[0]*10**5\nfor a in input().split():B[int(a)]+=1\nprint(max(sum(B[i:i+3])for i in range(10**5)))", "passed": true, "time": 0.21, "memory": 14232.0, "status": "done"}, {"code": "from collections import defaultdict\n\n\ndef main():\n    _ = input()\n    a = [int(an) for an in input().split()]\n    cnt = defaultdict(int)\n    for an in a:\n        cnt[an - 1] += 1\n        cnt[an] += 1\n        cnt[an + 1] += 1\n    print((max(cnt.values())))\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14192.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\nres=0\ncount=[0]*(10**5+2)\nfor i in range(N) :\n  count[a[i]]+=1\nfor i in range(10**5) :\n  x=count[i]+count[i+1]+count[i-1]\n  res=max(res,x)\nprint(res)", "passed": true, "time": 0.22, "memory": 14328.0, "status": "done"}, {"code": "from collections import Counter\n\nn=int(input())\nl=list(map(int,input().split()))\n\na=[i-1 for i in l]\nb=[i+1 for i in l]\n\nl=Counter(l+a+b)\n\nprint(l.most_common()[0][1])", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "from collections import defaultdict\n\nn = int(input())\narr = list(map(int, input().split()))\n\nd = defaultdict(int)\nfor x in arr:\n    d[x] += 1\n\na = d[0] + d[1] + d[2]\nans = [a]\n\nfor i in range(max(arr) - 2):\n    a -= d[i]\n    a += d[i + 3]\n    ans.append(a)\n\nprint(max(ans))", "passed": true, "time": 0.17, "memory": 23916.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\ndata=[0]*(10**5+2)\nfor i in a:\n  data[i]+=1\n  data[i+1]+=1\n  data[i+2]+=1\nprint(max(data))", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "n = int(input())\ncnt = [0]*100002\n\na = list(map(int,input().split()))\n\nfor v in a:\n    cnt[v] += 1\n    cnt[v+1] += 1\n    cnt[v+2] += 1\n    \n#print(cnt)\nprint((max(cnt)))\n\n", "passed": true, "time": 0.14, "memory": 14024.0, "status": "done"}, {"code": "from collections import defaultdict\nd=defaultdict(int)\nN=int(input())\na=list(map(int,input().split()))\nfor x in a:\n    d[x]+=1\n    d[x-1]+=1\n    d[x+1]+=1\nprint(max(d.values()))", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "\nN = int(input())\nl = list(map(int,input().split()))\n\nflag = [0] * (max(l)+2)\n\nminone = 0\nfor i in l:\n    if i == 0:\n        minone+= 1\n    else:\n        flag[i-1] += 1\n    flag[i] += 1\n    flag[i+1] += 1\n\nprint(max(max(flag),minone))", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\nN = int(input())\na = list(map(int, input().split()))\n\ncount = [0] * (10**5+1)\n\nfor i in range(N):\n    count[a[i]] += 1\n    if a[i]-1 >=0:\n        count[a[i]-1] += 1\n    if a[i]+1 <=10**5:\n        count[a[i]+1] += 1\n\nmax_value = max(count)\n#max_index = count.index(max_value)\nprint(max_value)", "passed": true, "time": 0.15, "memory": 14180.0, "status": "done"}, {"code": "N = int(input())\nA = [int(x) for x in input().split()]\n\ndata = {}\nfor a in A:\n    for i in range(3): #a-1,a,a+1\u3092\u30ab\u30a6\u30f3\u30c8\n        if a-1+i in data:\n            data[a-1+i] += 1\n        else:\n            data[a-1+i] = 1\n            \n#\u30ab\u30a6\u30f3\u30c8\u3057\u305f\u3082\u306e\u306e\u6700\u5927\u5024\u304c\u7b54\u3048\nans = 0\nfor d in data.values():\n    ans = max(ans, d)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "import collections\nn=int(input())\na=list(map(int,input().split()))\na1=[x-1 for x in a]\na2=[x+1 for x in a]\nb=a+a1+a2\nc=collections.Counter(b)\n\nprint(max(c.values()))", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split())) \n\ndp=[0 for i in range(max(a)+1)]\nfor i in range(n):\n    dp[a[i]]+=1\n \nans=0\n\nif len(dp)==1:\n    ans=dp[0]\nelse:\n    for i in range(1,len(dp)-1):\n        ans=max(ans,dp[i-1]+dp[i]+dp[i+1])\n \nprint(ans)", "passed": true, "time": 0.17, "memory": 14304.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\n\n\nQ=[0]*(max(a)+3)\n\nfor i in a:\n    Q[i]+=1\n    Q[i+1]+=1\n    Q[i+2]+=1\nprint(max(Q))", "passed": true, "time": 0.32, "memory": 14740.0, "status": "done"}, {"code": "import collections\n\nN = int(input())\nAs = sorted(list(map(int, input().split())))\nc = collections.Counter(As)\n\nL = [0] * (10 ** 5 + 1)\nM = [0] * (10 ** 5 + 1)\nfor (x, y) in list(c.items()):\n    L[x] = y\n\nfor i in range(0, (10 ** 5)):\n    M[i] = L[i - 1] + L[i] + L[i + 1]\n\nprint((max(M)))\n", "passed": true, "time": 0.19, "memory": 14944.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nA = [i + 1 for i in A]\n\nbucket = [0] * (10 ** 5 + 10)\n\nfor a in A:\n    bucket[a - 1] += 1\n    bucket[a] += 1\n    bucket[a+1] += 1\n\nprint(max(bucket))", "passed": true, "time": 1.1, "memory": 14328.0, "status": "done"}, {"code": "from collections import Counter\nimport copy\n\n\ndef LI():\n    return list(map(int, input().split()))\n\n\nN = int(input())\nA = LI()\nB = Counter(A)\nA = copy.copy(B)\n\nfor k, v in B.items():\n\n    if k-1 in A:\n        A[k-1] += v\n    else:\n        A[k-1] = v\n    if k+1 in A:\n        A[k+1] += v\n    else:\n        A[k+1] += v\n\nprint(max(A.values()))", "passed": true, "time": 0.31, "memory": 14248.0, "status": "done"}, {"code": "from collections import defaultdict\n\nn = int(input())\narr = list(map(int, input().split()))\n\nd = defaultdict(int)\n\nfor x in arr:\n    d[x] += 1\n    d[x - 1] += 1\n    d[x + 1] += 1\n\nresult = [y for x, y in d.items()]\n\nprint(max(result))", "passed": true, "time": 0.15, "memory": 14088.0, "status": "done"}, {"code": "import collections\n\nn = int(input())\na_list = list(map(int, input().split()))\nmax_cnt = 0\n\nc = collections.Counter(a_list)\n\nfor i in range(max(c.keys()) + 1) :\n    cnt = c[i] + c[i + 1] + c[i + 2]\n    \n    if max_cnt < cnt :\n        max_cnt = cnt\n\nprint(max_cnt)", "passed": true, "time": 0.35, "memory": 14268.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\n\np=[]\nfor i in range(n):\n    p.append(a[i]-1)\n    p.append(a[i])\n    p.append(a[i]+1)\n\nfrom collections import Counter\n\nc=Counter(p).most_common()\n\nm = list(c)[0][0]\n\nans=0\n\nfor i in range(n):\n    if abs(a[i]-m)<=1:\n        ans+=1\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14060.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\nX = [0]*(10**5+5)\nfor a in A:\n    X[a]+=1\n    X[a+1]+=1\n    X[a-1]+=1\nprint(max(X))", "passed": true, "time": 0.29, "memory": 14036.0, "status": "done"}, {"code": "import statistics\nN = int(input())\nA = list(map(int, input().split()))\nans = []\nfor a in A:\n    ans.append(a)\n    ans.append(a-1)\n    ans.append(a+1)\nmode = statistics.mode(ans)\nprint(ans.count(mode))", "passed": true, "time": 1.19, "memory": 14252.0, "status": "done"}, {"code": "import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n    n = int(input())\n    a = list(map(int, input().split()))\n    cnt = [0] * (max(a)+3)\n    \n    for i in a:\n        cnt[i-1] += 1\n        cnt[i] += 1\n        cnt[i+1] += 1\n        \n    print(max(cnt))\n    \ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14196.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\nmode = [0]*(10**5+2)\nfor i in range(len(a)):\n    k = a[i]\n    if(a == 0):\n        mode[k] += 1\n        mode[k+1] += 1\n    else:\n        mode[k-1] += 1\n        mode[k]   += 1\n        mode[k+1] += 1\n\nprint(max(mode))", "passed": true, "time": 0.25, "memory": 14164.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nans = 0\nA.sort()\na=0\nb=0\nc=1\n\nfor i in range(N-1):\n  if A[i] == A[i+1]:\n    a += 1\n    b += 1\n    c += 1\n  elif A[i]+1 == A[i+1]:\n    if ans < a:\n      ans = a\n    a = b\n    a += 1\n    b = c\n    b += 1\n    c = 1\n  elif A[i]+2 == A[i+1]:\n    if ans < a:\n      ans = a\n    if ans < b:\n      ans = b\n    a = c\n    a += 1\n    b = 1\n    c = 1\n  else:\n    if ans < a:\n      ans = a\n    if ans < b:\n      ans = b\n    if ans < c:\n      ans = c\n    a = 1\n    b = 1\n    c = 1\n\nif ans < a:\n      ans = a\nif ans < b:\n      ans = b\nif ans < c:\n      ans = c\nprint(ans)", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 21 23:37:30 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\n\nA = [int(x) for x in input().split()]\n\nd = [0]*(10**5 + 1)\n\nfor a in A:\n    if a - 1 >= 0:\n        d[a-1] += 1\n    d[a] += 1\n    d[a+1] += 1\n\nans = max(d)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14112.0, "status": "done"}, {"code": "import collections\n\nN=int(input())\nList = list(map(int, input().split()))\nsumList = []\nfor i in range(N):\n  sumList.append(List[i])\n  sumList.append(List[i]+1)\n  sumList.append(List[i]-1)\nc = collections.Counter(sumList)\nprint(c.most_common()[0][1])", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "N=int(input())\na=list(map(lambda x: int(x), input().split(\" \")))\n#print(a)\nsums=[0]*(10**5+1)\n#print(sums)\n\nfor val in a:\n  #print(val)\n  if val-1>=0:\n    sums[val-1]=sums[val-1]+1\n  sums[val]=sums[val]+1\n  if val+1<=10**5:\n    sums[val+1]=sums[val+1]+1\n\nprint(max(sums))", "passed": true, "time": 0.15, "memory": 14320.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\ncount = [0] * (10 ** 5 + 1)\n\nfor a in A:\n  count[a] += 1\n  \nans = 0  \nfor i in range(1, 10 ** 5):\n  X = count[i-1] + count[i] + count[i+1]\n  ans = max(ans, X)\n  \nprint(ans)", "passed": true, "time": 0.22, "memory": 14092.0, "status": "done"}, {"code": "n = int(input())\nlis = list(map(int, input().split()))\ncon = [0] * (10**5+2)\n\nfor v in lis:\n  con[v] +=1\n  con[v+1] += 1\n  con[v+2] += 1\n\nprint(max(con))", "passed": true, "time": 0.15, "memory": 14004.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nco = [0 for i in range(100002)]\n\nfor i in A:\n    co[i] += 1\n\nans = 0\nfor i in range(100001):\n    if i == 0:\n        x = co[0] + co[1]\n    else:\n        x = co[i - 1] + co[i] + co[i + 1]\n\n    ans = max(ans, x)\nprint(ans)\n", "passed": true, "time": 0.23, "memory": 14204.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int, input().split()))\nans = 0\nl = [0]*(10**5+2)\nfor i in range(n):\n    l[a[i]] +=1\nfor i in range(10**5):\n    x = l[i] +l[i+1]+l[i-1]\n    ans = max(ans,x)\nprint(ans)", "passed": true, "time": 0.22, "memory": 14228.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nK = max(A)\nls = [0 for i in range(K+2)]\nfor i in range(N):\n    if A[i] == 0:\n        ls[A[i]] += 1\n        ls[A[i]+1] += 1\n    else:\n        ls[A[i]-1] += 1\n        ls[A[i]] += 1\n        ls[A[i]+1] += 1\nprint(max(ls))", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "import sys\nfrom collections import Counter\n\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncounter = Counter(A)\nans = 0\nfor value, count in counter.items():\n    if value - 1 in counter:\n        count += counter[value - 1]\n    if value + 1 in counter:\n        count += counter[value + 1]\n    ans = max(ans, count)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "import sys\n\ninput = sys.stdin.readline\n\nn = int(input())\n\na_list = list(map(int, input().split()))\nsort_a_list = sorted(a_list)\n\nl = 0\nr = 0\nans = 0\nmax_ans = 0\nsabun = 0\n#print(sort_a_list)\n\nwhile (r < n):\n    #print(l,r)\n    #print(ans)\n    #print(sabun)\n    if (sabun <= 2):\n        if sort_a_list[r] - sort_a_list[l] > 2:\n            l += 1\n            sabun = sort_a_list[r] - sort_a_list[l]\n            ans -= 1\n            continue\n        ans += 1\n        max_ans = max(max_ans,ans)\n        r += 1\n        if r >= n:\n            break\n        sabun = sort_a_list[r] - sort_a_list[l]\n        \n    else:\n        l += 1\n        sabun = sort_a_list[r] - sort_a_list[l]\n        ans -= 1\nprint(max_ans)", "passed": true, "time": 0.22, "memory": 14152.0, "status": "done"}, {"code": "import collections\nn = int(input())\nl = sorted(list(map(int, input().split())) )\nc = collections.Counter(l)\nL = [0]*(10**5+1)\nM = [0]*(10**5+1)\n \nfor x,y in c.items():\n    L[x] += y\n \nM[0] = L[0]\nM[10**5] = L[10**5]\nfor i in range(1,10**5):\n    M[i] = L[i-1] + L[i] + L[i+1]\nprint(max(M))", "passed": true, "time": 0.19, "memory": 14884.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n    a[i] -= 1\n\nc = [0 for _ in range(100005)]\n\nfor i in range(n):\n    val = a[i]\n    c[val - 1] += 1\n    c[val] += 1\n    c[val + 1] += 1\n\nans = 0\nfor i in range(100005):\n    ans = max(ans, c[i])\n\nprint(ans)", "passed": true, "time": 0.19, "memory": 14436.0, "status": "done"}, {"code": "# coding: utf-8\n\n\ndef main():\n    _ = int(input())\n    A = list(map(int, input().split()))\n    B = [0] * 100002\n    ans = 0\n\n    for a in A:\n        if a != 0: B[a - 1] += 1\n        B[a] += 1\n        B[a + 1] += 1\n\n    ans = max(B)\n    \n    print(ans)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "n=int(input())\na=sorted(list(map(int, input().split(\" \"))))\ncounter = [0 for i in range(10 ** 5 + 2)]\nans = 0\n\nfor i in range(n):\n  counter[a[i]] += 1\n#print(counter)\nfor i in range(1, 10 ** 5 + 1):\n  temp = sum(counter[i-1:i+2])\n  ans = max(ans, temp)\nprint(ans)", "passed": true, "time": 0.26, "memory": 14188.0, "status": "done"}, {"code": "import collections\n\nN = int(input())\na = list(map(int, input().split()))\n\nfor i in range(len(a)):\n    if a[i] > 0:\n        a.append(a[i]-1)\n    a.append(a[i]+1)\n\nres = collections.Counter(a)\n\nprint(max(res.values()))", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "N = int(input())\na = map(int, input().split())\n\nresult_num_list = [0] * (10 ** 5 + 5)\nfor i in a:\n    result_num_list[i-1] += 1\n    result_num_list[i] += 1\n    result_num_list[i+1] += 1\n\nprint(max(result_num_list))", "passed": true, "time": 0.15, "memory": 14308.0, "status": "done"}, {"code": "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n    n = int(input())\n    a = list(map(int, input().split()))\n    m = 10**5\n    l = [0]*m\n    for i in range(n):\n        if a[i] >= 1:\n            l[a[i]-1] += 1\n        l[a[i]] += 1\n        if a[i] < m-1:\n            l[a[i]+1] += 1\n    print(max(l))\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14044.0, "status": "done"}, {"code": "n = int(input())\ncnt = [0]*100002\n\na = list(map(int,input().split()))\n\nfor v in a:\n    cnt[v-1] += 1\n    cnt[v] += 1\n    cnt[v+1] += 1\n    \n#print(cnt)\nprint((max(cnt)))\n\n", "passed": true, "time": 0.31, "memory": 14040.0, "status": "done"}, {"code": "n = int(input())\narr = [int(x) for x in input().split()]\ncnt = [0] * (10 ** 5 + 1)\nfor a in arr:\n    cnt[a] += 1\n    cnt[a+1] += 1\n    if a > 0:\n        cnt[a-1] += 1\n\nprint(max(cnt))", "passed": true, "time": 0.27, "memory": 14336.0, "status": "done"}, {"code": "import collections\nn = int(input())\na = list(map(int, input().split()))\na1 = [x - 1 for x in a]\na2 = [x + 1 for x in a]\nb = a + a1 + a2\nc = collections.Counter(b)\n\nprint(max(c.values()))", "passed": true, "time": 0.27, "memory": 14196.0, "status": "done"}, {"code": "from sys import stdin, stdout # only need for big input\n\ndef increment_dict(a_dict, element):\n    if element in a_dict:\n        a_dict[element] = a_dict[element] + 1\n    else:\n        a_dict[element] = 1\n\ndef solve():\n    n = int(input())\n    a = list(map(int, input().split()))\n    mp = dict()\n    best_count = 0\n    for num in a:\n        increment_dict(mp, num)\n        increment_dict(mp, num - 1)\n        increment_dict(mp, num + 1)\n        best_count = max(best_count, mp[num], mp[num-1], mp[num+1])\n    print(best_count)\n\ndef main():\n    solve()\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14260.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\n\nans = [0] * (max(A) + 2)\n\nfor a in A:\n    if a == 0:\n        ans[a] += 1\n        ans[a + 1] += 1\n    if a != 0:\n        ans[a - 1] += 1\n        ans[a] += 1\n        ans[a + 1] += 1\n\nprint((max(ans)))\n", "passed": true, "time": 0.15, "memory": 14332.0, "status": "done"}, {"code": "N = int(input())\na = sorted([int(c) for c in input().split()])\n#2\u56de\u306e\u5909\u308f\u308a\u76ee\u3092\u8a18\u61b6\nc1,c2,c3 = [0,0,0]\nma = 1\nfor i in range(N):\n    if i > 0:\n        if a[i]==a[i-1]+1:\n            c1 = c2 \n            c2 = c3\n            c3 = i\n        elif a[i]!=a[i-1]:\n            c1,c2,c3=[i,i,i]\n    if ma < i - c1+1:\n        ma = i - c1+1\n\nprint(ma)", "passed": true, "time": 0.2, "memory": 14300.0, "status": "done"}, {"code": "N = int(input())\nA_list = list(map(int, input().split()))\nA_dict = dict()\nfor a in A_list:\n    if A_dict.get(a) is None:\n        A_dict[a] = 1\n    else:\n        A_dict[a] += 1\nans = 0\nfor key, val in list(A_dict.items()):\n    temp = 0\n    if A_dict.get(key - 1) is not None:\n        temp += A_dict.get(key - 1)\n    if A_dict.get(key) is not None:\n        temp += A_dict.get(key)\n    if A_dict.get(key + 1) is not None:\n        temp += A_dict.get(key + 1)\n    ans = max(temp, ans)\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14140.0, "status": "done"}, {"code": "N=input()\nls=[int(s) for s in input().split()]\nnum=[0 for s in range(1000001)]\nfor i in ls:\n  num[i]+=1\nans=[num[i-1]+num[i]+num[i+1] for i in range(100000)]\nprint(max(ans))", "passed": true, "time": 0.63, "memory": 23156.0, "status": "done"}, {"code": "input();c=[0]*10**6\nfor i in input().split():\n for j in(0,1,2):c[int(i)+j]+=1\nprint(max(c))", "passed": true, "time": 0.37, "memory": 21132.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\ncount=[0 for _ in range(100001)]\nfor x in a:\n    count[x]+=1\n    count[x+1]+=1\n    if x>0:\n        count[x-1]+=1\nprint((max(count)))\n", "passed": true, "time": 0.16, "memory": 14188.0, "status": "done"}, {"code": "N=int(input())\nA=list(map(int,input().split()))\n\nans=0\n\ncnt=[0]*(10**5+10)\nfor i in range(N):\n    cnt[A[i]]+=1\n\nfor i in range(0,100000):\n    sum=cnt[i]+cnt[i+1]+cnt[i+2]\n    ans=max(ans,sum)\n\nprint(ans)", "passed": true, "time": 0.41, "memory": 14232.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int, input().split(\" \")))\n#print(a)\nsums=[0]*(10**5)\n#print(sums)\n\nfor val in a:\n  #print(val)\n  if val-1>=0:\n    sums[val-1]=sums[val-1]+1\n  sums[val]=sums[val]+1\n  if val+1<10**5:\n    sums[val+1]=sums[val+1]+1\n\nprint(max(sums))", "passed": true, "time": 0.15, "memory": 14124.0, "status": "done"}, {"code": "from collections import defaultdict\n\nN = int(input())\na = tuple(map(int, input().split()))\ncnt = defaultdict(int)\n\nfor i in range(N):\n\tcnt[a[i]-1] += 1\n\tcnt[a[i]] += 1\n\tcnt[a[i]+1] += 1\nprint(max(cnt.values()))", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nans = 0\n \nl = [0]*100001\n \nfor i in a:\n  l[i] += 1\n\nfor i in range(len(l)-2):\n  ans = max(ans,l[i]+l[i+1]+l[i+2])\n  \nprint(ans)", "passed": true, "time": 0.29, "memory": 14316.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nimport collections\n\nlis = collections.Counter(a)\nans = 0\nmemo = 0\n#print(lis)\n\nfor i in range(10**5):\n    memo = lis[i-1] + lis[i] + lis[i+1]\n    #print(lis[i-1], lis[i], lis[i+1])\n    if memo > ans:\n        ans = memo\n\n\nprint(ans)\n\n\n\n", "passed": true, "time": 0.28, "memory": 14216.0, "status": "done"}, {"code": "N = int(input())\na = [int(x) for x in input().split()]\n\nM = max(a)\n\nC = [0] * (M + 1)\n\nfor i in range(N):\n    C[a[i]] += 1 \n\nans = 0\n\nfor i in range(1,M):\n    wa = C[i - 1] + C[i] + C[i + 1]\n    ans = max(ans, wa)\n\nif M <= 1:\n    ans = N\n\nprint(ans)", "passed": true, "time": 0.16, "memory": 14176.0, "status": "done"}, {"code": "#\uff08i+1 and i and i-1\uff09\u306e\u5408\u8a08\u6570\u304c\u4e00\u756a\u591a\u3044\u3068\u3053\u308d\u3092\u898b\u3064\u3051\u308b\nfrom collections import Counter\nans = []\nN = int(input())\na = list(map(int,input().split()))\nnum = Counter(a)\nfor i in set(a):\n    ans.append(num[i] + num[i+1] + num[i-1])\n    \nprint(max(ans))", "passed": true, "time": 0.15, "memory": 14084.0, "status": "done"}, {"code": "#!/usr/bin/env python3\ncnt=[0]*100002\ninput()\nfor x in map(int,input().split()):\n    cnt[x]+=1\n    cnt[x+1]+=1\n    cnt[x+2]+=1\nprint(max(cnt))", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\n \nans = [0] * (max(A) + 2)\n \nfor a in A:\n    if a == 0:\n        ans[a] += 1\n        ans[a + 1] += 1\n    if a != 0:\n        ans[a - 1] += 1\n        ans[a] += 1\n        ans[a + 1] += 1\nprint(max(ans))", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nnums = [0]*100000\nans_list=[]\n\nfor i in range(N):\n  nums[A[i]] += 1\n\nfor j in range(1,99999):\n  ans_list.append(nums[j-1]+nums[j]+nums[j+1])\n\nprint(max(ans_list))", "passed": true, "time": 0.33, "memory": 15064.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().strip().split()))\n\ndp=[0 for n in range(max(a)+1)]\nfor n in range(N):\n    dp[a[n]]+=1\n\nans=0\nif len(dp)==1:\n    ans=dp[0]\nelse:\n    for n in range(1,len(dp)-1):\n        ans=max(ans,dp[n-1]+dp[n]+dp[n+1])\n\nprint(ans)\n", "passed": true, "time": 0.16, "memory": 14232.0, "status": "done"}, {"code": "import sys\nN = int(input())\nA = list(map(int, input().split()))\n\nif N == 1:\n    print(1)\n    return\n    \ncnt = [0 for _ in range(10**5+1)]\nfor a in A:\n    if a == 0:\n        cnt[a] += 1\n        cnt[a+1] += 1\n    else:\n        cnt[a-1] += 1\n        cnt[a] += 1\n        cnt[a+1] += 1\n    \nprint(max(cnt))", "passed": true, "time": 0.24, "memory": 14116.0, "status": "done"}, {"code": "#10 C - Together\nN = int(input())\na = list(map(int,input().split()))\na = sorted(a, reverse = True)\na_set = set(a)\n\n#a\u306e\u5404\u8981\u7d20\u306e\u500b\u6570\u3092\u30ab\u30a6\u30f3\u30c8\na_cnt = [0]*(max(a)+2)#0\u304b\u3089max(a)+1\u307e\u3067\nfor i in a:\n    a_cnt[i] += 1\n\nmcnt = 0\nfor j in a:\n    cnt = a_cnt[j]\n    if j-1 in a_set:\n        cnt += a_cnt[j-1]\n    if j+1 in a_set:\n        cnt += a_cnt[j+1]\n    mcnt = max(mcnt,cnt)    \nprint(mcnt)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "import collections\nN = int(input())\nlsA = list(map(int,input().split()))\ncounterA = collections.Counter(lsA)\nans = 0\nfor X in range(1,10**5+1):\n    b1 = counterA[X-1]\n    b2 = counterA[X]\n    b3 = counterA[X+1]\n    ans = max(ans,sum([b1,b2,b3]))\nprint(ans)", "passed": true, "time": 0.37, "memory": 14252.0, "status": "done"}, {"code": "n = int(input())\na_lst = list(map(int, input().split()))\nfor i in range(n):\n    a_lst[i] += 1\n\nmax_a = max(a_lst)\ncount_lst = [0] * (max_a + 2)\n\n\nfor i in range(n):\n    a = a_lst[i]\n    index1 = a - 1\n    index2 = a\n    index3 = a + 1\n\n    count_lst[index1] += 1\n    count_lst[index2] += 1\n    count_lst[index3] += 1\n\nmaximum = max(count_lst)\nprint(maximum)", "passed": true, "time": 0.14, "memory": 14248.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nb = []\nfor i in range(n):\n    b += [a[i],a[i]+1,a[i]-1]\nimport collections\nc = collections.Counter(b)\nprint(c.most_common()[0][1])", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "'''\nCreated on 2020/10/01\n\n@author: harurun\n'''\nimport sys\npin=sys.stdin.readline\n\ndef main():\n  N=int(pin())\n  a=list(map(int,pin().split()))\n  d=[0]*(10**5)\n  for i in a:\n    d[i]+=1\n  ans=0\n  for i in range(10**5-2):\n    ans=max(ans,d[i]+d[i+1]+d[i+2])\n  print(ans)\n  return \nmain()", "passed": true, "time": 0.21, "memory": 14392.0, "status": "done"}, {"code": "n = int(input())\nnumbers = list(map(int, input().split()))\nnumber_colle = [0] * (10 ** 5 + 2)\nfor i in range(n):\n    choise = numbers[i] + 1\n    for j in [-1, 0, 1]:\n        number_colle[choise + j] += 1\n\nprint((max(number_colle)))\n", "passed": true, "time": 0.22, "memory": 14332.0, "status": "done"}, {"code": "import collections\n\nn = int(input())\na = list(map(int,input().split()))\nc = a + [i-1 for i in a] + [i+1 for i in a]\ncntList = collections.Counter(c)\n\nprint((cntList.most_common()[0][1]))\n", "passed": true, "time": 0.14, "memory": 14040.0, "status": "done"}]