#!/bin/python import sys n = int(raw_input().strip()) a = map(int,raw_input().strip().split(' ')) d=dict() for i in a: if i not in d: d[i]=1 else: d[i]+=1 m=0 for i in d: temp=d[i] if i+1 in d: temp+=d[i+1] m=max(m,temp) print m