n = int(raw_input()) narr = map(int,raw_input().split(" ")) res = 2 #ans >= 2 for num in narr: candlen = len([j for j in narr if j == num or j == num + 1]) if candlen > res: res = candlen print res