#!/bin/python3 import sys n = int(input().strip()) a = [int(a_temp) for a_temp in input().strip().split(' ')] new_a=sorted(list(set(a))) maxi=-1 store=[] for x in range(len(new_a)-1): if (a.count(new_a[x+1])+a.count(new_a[x])) > maxi and abs((new_a[x+1])-(new_a[x]))<=1: maxi=(a.count(new_a[x+1]) + a.count(new_a[x])) store.append(a.count(new_a[x])) store.append(a.count(new_a[len(new_a)-1])) if len(store)!=0:print(max(maxi,max(store))) else:print(maxi)