#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;
bool isprime(int p) {
  if (p == 1) return false;
  for (int i = 2; i < p; i++) {
    if (p % i == 0) return false;
  }
  return true;
}
ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll keta(ll n) {
  ll res = 0;
  while (n >= 1) {
    res += n % 10;
    n /= 10;
  }
  return res;
}
ll modpow(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y % 2) {
      res *= x;
      res %= mod;
    }
    x = x * x % mod;
    y /= 2;
  }
  return res;
}
ll nCk(ll n, ll k) {
  ll a = 1, b = 1;
  for (int h = n - k + 1; h <= n; h++) {
    a *= h;
    a %= mod;
  }
  for (int h = 1; h <= k; h++) {
    b *= h;
    b %= mod;
  }
  return a * modpow(b, mod - 2) % mod;
}
ll par[2134567];
ll depth[2134567];
void init(ll n) {
  for (int i = 0; i <= n; i++) {
    par[i] = i;
    depth[i] = 0;
  }
}
ll find(ll x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
void unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x == y) {
    return;
  }
  if (depth[x] < depth[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (depth[x] == depth[y]) depth[x]++;
  }
}
bool same(ll x, ll y) { return find(x) == find(y); }
signed main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s, t;
  ll n, m, cnt = 0, ans = 0, a, b, c, d, k;
  cin >> n >> k;
  vector<ll> dp(n, INF);
  for (int h = 0; h < n; h++) {
    cin >> a;
    cout << lower_bound(dp.begin(), dp.end(), INF) - dp.begin() << endl;
    if (dp[lower_bound(dp.begin(), dp.end(), a - 3) - dp.begin()] <= a + 3) {
      dp[lower_bound(dp.begin(), dp.end(), a - 3) - dp.begin()] = a;
    }
  }
  ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
  cout << ans << endl;
  return 0;
}
