import std.stdio : readf, readln, writefln;
import std.algorithm : map, count, max;
import std.array : split, array;
import std.conv : to;
import std.string : chomp;
import std.math : abs;

void main() {
	immutable numsCount = readln(). chomp.to!int;
	immutable nums = readln().chomp.split.map!(to!int).array;
	size_t countMatch(int x) {
		return nums.count!(n => abs(x - n) <= 1);
	}

	size_t maxCount = 0;
	foreach(n; nums) {
		maxCount = max(countMatch(n - 1), countMatch(n), countMatch(n + 1), maxCount);
	}
	writefln("%d", maxCount);
}