#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int b[N], ans[N], n;
int mxB[N][N];
pair<int, int> a[N];
pair<int, pair<int, int> > mxAns;
int besti, bestj, bestz;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int(i) = (1); (i) <= (n); ++(i)) cin >> a[i].first, a[i].second = i;
  sort(a + 1, a + 1 + n);
  reverse(a + 1, a + 1 + n);
  for (int(i) = (1); (i) <= (n); ++(i)) b[i] = a[i].first - a[i + 1].first;
  for (int(i) = (1); (i) <= (n); ++(i)) mxB[i][i] = i;
  for (int len = 2; len <= n; ++len) {
    for (int i = 1; i + len - 1 <= n; ++i) {
      int j = i + len - 1;
      mxB[i][j] = (b[mxB[i][j - 1]] >= b[j] ? mxB[i][j - 1] : j);
    }
  }
  for (int(i) = (1); (i) <= (n); ++(i)) {
    for (int(j) = (i + 1); (j) <= (n); ++(j)) {
      int cnt1 = i, cnt2 = j - i;
      int l = j + max(1, max(cnt1 + 1, cnt2 + 1) / 2),
          r = j + min(n - j, 2 * min(cnt1, cnt2));
      int z = n;
      if (l <= r) z = mxB[l][r];
      int cnt3 = z - j;
      int mx = max(cnt1, max(cnt2, cnt3)), mn = min(cnt1, min(cnt2, cnt3));
      if (mx > 2 * mn || !mn) continue;
      pair<int, pair<int, int> > cur = {b[i], {b[j], b[z]}};
      if (cur > mxAns) {
        besti = i;
        bestj = j;
        bestz = z;
        mxAns = cur;
      }
    }
  }
  for (int(i) = (1); (i) <= (besti); ++(i)) ans[a[i].second] = 1;
  for (int(i) = (besti + 1); (i) <= (bestj); ++(i)) ans[a[i].second] = 2;
  for (int(i) = (bestj + 1); (i) <= (bestz); ++(i)) ans[a[i].second] = 3;
  for (int(i) = (bestz + 1); (i) <= (n); ++(i)) ans[a[i].second] = -1;
  for (int(i) = (1); (i) <= (n); ++(i)) cout << ans[i] << ' ';
  cout << '\n';
}
