#!/bin/python import sys def solution(L): D = {} M = [] for x in L: if x in D: D[x] += 1 else: M.append(x) D[x] = 1 i = 0 j = len(M) result = 2 while i < j-1: if (M[i+1] - M[i]) <= 1: total = D[M[i]] + D[M[i+1]] if total > result: result = total i += 1 for x in D: if D[x] > result: result = D[x] return result if __name__ == "__main__": N = int(raw_input().strip()) L = map(int, raw_input().strip().split(' ')) L = sorted (L) print solution(L)