#!/bin/python import sys n = int(raw_input().strip()) a = map(int,raw_input().strip().split(' ')) a = sorted(a) c = 0 temp = 0 for i in range(len(a)): for j in range(i, len(a)): if a[j]-a[i] < 2: c += 1 else: break if temp < c: temp = c c = 0 print temp