#!/bin/python3 import sys n = int(input().strip()) a = [int(a_temp) for a_temp in input().strip().split(' ')] w = {e:[] for e in a} for e in a: if e-1 in w: w[e-1].append(e) w[e].append(e) print(max(map(len,w.values())))