Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for v in range(min(A), max(A) + 1):
    count = A.count(v - 1) + A.count(v) + A.count(v + 1)
    if ans < count:
        ans = count
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for v in range(min(A), max(A) + 1):
    ans = max(A.count(v - 1) + A.count(v) + A.count(v + 1), ans)
print(ans)


Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for v in range(min(A), max(A) + 1):
    count = A.count(v - 1) + A.count(v) + A.count(v + 1)
    if ans < count:
        ans = count
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
count = []
for v in range(min(A), max(A) + 1):
    count.append(A.count(v - 1) + A.count(v) + A.count(v + 1))
print(max(count))

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
check = set(A + [a - 1 for a in A] + [a + 1 for a in A])
ans = 0
for v in check:
    ans = max(A.count(v - 1) + A.count(v) + A.count(v + 1), ans)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for v in range(min(A), max(A) + 1):
    ans = max(A.count(v - 1) + A.count(v) + A.count(v + 1), ans)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for v in range(min(A), max(A) + 1):
    count = 0
    for a in A:
        if v - 1 <= a <= v + 1:
            count += 1
    ans = max(count, ans)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
check = set(A + [a - 1 for a in A] + [a + 1 for a in A])
ans = 0
for v in check:
    count = 0
    for a in A:
        if v - 1 <= a <= v + 1:
            count += 1
    ans = max(count, ans)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
check = set(A + [a - 1 for a in A] + [a + 1 for a in A])
ans = 0
for v in check:
    count = 0
    for a in A:
        if v - 1 <= a <= v + 1:
            count += 1
    ans = max(count, ans)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
start, end = min(A), max(A) + 1
for v in range(start, end):
    ans = max(C[v - 1] + C[v] + C[v + 1], ans)
print(ans)