#!/bin/python import sys n = int(raw_input().strip()) a = map(int,raw_input().strip().split(' ')) # put all of them into a hashtable/dictionary dict = {} for i in a: if (dict.has_key(i) == False): dict[i] = 1 else: dict[i] = dict[i] + 1 L = dict.keys() max = 0 if (len(L) == 1): if (dict[L[0]] > max): max = dict[L[0]] for j in range(len(L)-1): if (dict[L[j]] > max): max = dict[L[j]] if (abs(L[j] - L[j+1]) <= 1 and dict[L[j]] + dict[L[j+1]] > max): max = dict[L[j]] + dict[L[j+1]] print max