Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

if max(a)==min(a):
  print(n)
else:
  ans=1
  b=[0]*(10**6)
  for i in range(max(a)+1):
    b[i]=a.count(i)
  for i in range(10**5+3):
    ans=max(ans,b[i]+b[i+1]+b[i+2])
  print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
b=[0]*(10**5+2)
if a[0]==a[-1]:
  print(n)
else:
  for i in range(a[-1]+1):
    b[i]=a.count(i)
  for i in range(a[-1]-1):
    ans=max(ans,b[i]+b[i+1]+b[i+2])
  print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
b=[0]*(10**5+2)
if a[0]==a[-1]:
  print(n)
else:
  for i in range(10**5 + 2):
    b[i]=a.count(i)
  for i in range(10**5 -1):
    ans=max(ans,sum(b[i:i+3]))
  print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
b=[0]*(a[-1]-a[0]+2)
if a[0]==a[-1]:
  print(n)
else:
  for i in range(a[0]-1,a[-1]+1):
    b[i-a[0]+1]=a.count(i)
  for i in range(n+1):
    ans=max(ans,sum(b[i:i+3]))
  print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
b=[]
if a[0]==a[-1]:
  print(n)
else:
  for i in range(a[0]-1,a[-1]+1):
    b+=[a.count(i)]
  for i in range(n+1):
    ans=max(ans,sum(b[i:i+3]))
  print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
if a[0]==a[-1]:
  print(n)
else:
  for i in range(a[0],a[-1]):
    ans=max(ans,a.count(i)+a.count(i-1)+a.count(i+1))
  print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
if a[0]==a[-1]:
  print(n)
else:
  for i in range(a[0],a[-1]):
    ans=max(ans,a.count(i)+a.count(i-1)+a.count(i+1))
  print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)