#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int a[100005], last[100005], len[100005];
int read()
{
int x = 0, w = 1;
char ch = 0;
while (ch < '0' || ch > '9')
{
if (ch == '-')
w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = x * 10 + (ch - '0');
ch = getchar();
}
return x * w;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
a[i] = read();
sort(a, a + n);
int ans = 100001;
int last_group = -1;
for (int i = 0; i < n; i++)
{
int index = lower_bound(last, last + last_group + 1, a[i] - 1) - last;
while (index < last_group && last[index + 1] == a[i] - 1)
index++;
if (index > last_group)
{
last_group++;
last[last_group] = a[i];
len[last_group]++;
}
else
{
last[index] = a[i];
len[index]++;
}
}
for (int i = 0; i <= last_group; i++)
ans = min(ans, len[i]);
cout << ans;
return 0;
}