# !/bin/python3 import sys n = int(input().strip()) a = [int(a_temp) for a_temp in input().strip().split(' ')] c = 0 for i, x in enumerate(a): temp1 = 0 temp2 = 0 for y in a[i + 1:]: if -1 <= x - y <= 0: temp1 += 1 if 0 <= x - y <= 1: temp2 += 1 if temp1 > c: c = temp1 if temp2 > c: c = temp2 print(c+1)