Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])
  
  return max_n

ptint(n if len(set(a)) == 1 else func(a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])

  return max_n

print(n if len(set(a)) == 1 else func(a))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = [0] * (max(a)+1)

for i in a:
    count[i] += 1

max_n = 0
for j in range(1, len(count)-1):
    max_n = max(max_n, count[j] + count[j-1] + count[j+1])
max_n = max(max_n, count[-1] + count[-2])

print(max_n)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])

  return max_n

print(n if len(set(a)) == 1 else func(a))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = [0] * (max(a)+1)

for i in a:
    count[i] += 1

max_n = 0
for j in range(1, len(count)-1):
    max_n = max(max_n, count[j] + count[j-1] + count[j+1])
max_n = max(max_n, count[-1] + count[-2])

print(max_n)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])

  return max_n

print(n if len(set(a)) == 1 else func(a))

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

out = 0

for i in set(a):
    out = max(out, a.count(i)+a.count(i-1)+a.count(i+1))

print(out)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])

  return max_n

print(n if len(set(a)) == 1 else func(a))

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

out = 0

for i in set(a):
    cnt = 0
    for j in a:
        if j == i or j-1 == i or j+1 == i:
            cnt += 1
    out = max(out, cnt)

print(out)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])

  return max_n

print(n if len(set(a)) == 1 else func(a))

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

out = 0

for i in range(max(a)+1):
    cnt = 0
    for j in a:
        if j == i or j-1 == i or j+1 == i:
            cnt += 1
    out = max(out, cnt)

print(out)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

def func(a):
  count = [0] * (max(a)+1)

  for i in a:
      count[i] += 1

  max_n = 0
  for j in range(1, len(count)-1):
      max_n = max(max_n, count[j] + count[j-1] + count[j+1])
  max_n = max(max_n, count[-1] + count[-2])

  return max_n

print(n if len(set(a)) == 1 else func(a))