import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int[] xs) {
    int[int] d;
    for (int i = 0; i < xs.length; i++) {
        int x = xs[i];
        d[x - 1]++;
        d[x]++;
        d[x + 1]++;
    }

    int ans = 0;
    foreach (k, v; d) {
        ans = max(ans, v);
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}
