from collections import * N = int(input()) A = [0] * N for i in range(N): A[i] = int(input()) C = Counter(A) ans = 0 for a in A: ans = max(ans, C[a] + max(C[a+1], C[a-1])) print(ans)