#!/bin/python from collections import * import sys n = int(raw_input().strip()) a = map(int,raw_input().strip().split(' ')) cnt = Counter(a) sum = 0 temp1 = 0 temp2 = 0 for x in set(a): temp1 = cnt[x+1] + cnt[x] temp2 = cnt[x] + cnt[x-1] sum = max(sum,temp1,temp2) print sum