Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in range(100005):
    ary_count[i] = ary.count(i)

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Fixed submission:
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in ary:
    ary_count[i] += 1

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()

for x in ary:
    count += ary.count(x-1)
    count += ary.count(x)
    count += ary.count(x+1)
    if count > max_count:
        max_count = count
    count = 0

print(max_count)

Fixed submission:
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in ary:
    ary_count[i] += 1

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()

for x in ary:
    for i in range(nums):
        if ary[i] == x+1 or ary[i] == x or ary[i] == x-1:
            count += 1
        if ary[i] == x+2:
            break
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Fixed submission:
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in ary:
    ary_count[i] += 1

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0

for x in ary:
    for i in range(nums):
        if ary[i] == x+1 or ary[i] == x or ary[i] == x-1:
            count += 1
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Fixed submission:
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in ary:
    ary_count[i] += 1

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0

for x in range(max(ary)+1):
    for i in range(nums):
        if ary[i] == x+1 or ary[i] == x or ary[i] == x-1:
            count += 1
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Fixed submission:
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in ary:
    ary_count[i] += 1

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)