#!/bin/python import sys from collections import Counter n = int(raw_input().strip()) a = map(int,raw_input().strip().split(' ')) c = Counter(a) max_count = 0 for k, v in c.items(): if c[k] + c[k+1] > max_count: max_count = c[k] + c[k+1] print(max_count)