#!/bin/python3 import sys from collections import Counter n = int(input().strip()) a = [int(a_temp) for a_temp in input().strip().split(' ')] c = Counter(a) if len(c) == 1: print (n) else: m = [] for k in c: m.append(c[k]) if k-1 in c: m.append(c[k] + c[k-1]) if k+1 in c: m.append(c[k] + c[k+1]) print (max(m))