#!/bin/bash
read n
x=()
max=0
while read a; do
    (( ++x[a] ))
    (( max < a )) && (( max = a ))
done < <(xargs -n 1)

ans=0
for (( i = 1; i <= max; i++ )); do
    (( tmp = x[i - 1] + x[i] + x[i + 1] ))
    (( ans < tmp )) && (( ans = tmp ))
done    

echo "${ans}"
