#!/bin/python3 import sys n = int(input().strip()) a = [int(a_temp) for a_temp in input().strip().split(' ')] count = {} for nb in a: if nb in count: count[nb] += 1 else: count[nb] = 1 map_lst = list(count.keys()) sorted(map_lst) max_nb = 0 for i in range(len(map_lst) - 1): first = map_lst[i] second = map_lst[i + 1] if second - first <= 1 and count[first] + count[second] > max_nb: max_nb = count[map_lst[i]] + count[map_lst[i + 1]] elif count[first] > max_nb: max_nb = count[first] last = map_lst[len(map_lst) - 1] if count[last] > max_nb: max_nb = count[last] print(max_nb)