from collections import Counter if __name__ == "__main__": n = int(raw_input()) array = map(int, raw_input().split()) c = Counter(array) maxSize = 0 for x in c: size = c[x] + c[x+1] if size > maxSize: maxSize = size print maxSize