#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
const int MOD = 1e9 + 9;
int mod_sum(int a, int b) { return ((a + b) % MOD + MOD) % MOD; }
int mod_sub(int a, int b) { return ((a - b) % MOD + MOD) % MOD; }
int mod_mul(int a, int b) { return 1ll * a * b % MOD; }
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  a.push_back(make_pair(0, n));
  vector<int> delta(n);
  for (int i = 0; i < n; ++i) delta[i] = a[i].first - a[i + 1].first;
  vector<vector<pair<int, int> > > maxDelta(n, vector<pair<int, int> >(n));
  for (int i = 0; i < n; ++i) {
    pair<int, int> curMaxDelta = make_pair(delta[i], i);
    for (int j = i; j < n; ++j) {
      curMaxDelta = max(curMaxDelta, make_pair(delta[i], i));
      maxDelta[i][j] = curMaxDelta;
    }
  }
  tuple<int, int, int> bestDeltas, bestSplits;
  bestDeltas = make_tuple(-1, -1, -1);
  for (int i = 0; i < n; ++i) {
    int l1 = i + 1;
    for (int j = i + 1; j < n; ++j) {
      int l2 = j - i;
      if (l2 > 2 * l1 || l1 > 2 * l2) continue;
      int minL3 = max({1, (l1 + 1) / 2, (l2 + 1) / 2});
      int maxL3 = min(2 * l1, 2 * l2);
      int minK = j + minL3;
      int maxK = min(n - 1, j + maxL3);
      if (minK <= maxK) {
        for (int k = minK; k < maxK + 1; ++k) {
          int d1 = delta[i];
          int d2 = delta[j];
          int d3 = delta[k];
          auto curDeltas = make_tuple(d1, d2, d3);
          if (curDeltas > bestDeltas) {
            bestDeltas = curDeltas;
            bestSplits = make_tuple(i, j, k);
          }
        }
      }
    }
  }
  vector<int> ans(n, -1);
  for (int i = 0; i < get<0>(bestSplits) + 1; ++i) ans[a[i].second] = 1;
  for (int i = get<0>(bestSplits) + 1; i < get<1>(bestSplits) + 1; ++i)
    ans[a[i].second] = 2;
  for (int i = get<1>(bestSplits) + 1; i < get<2>(bestSplits) + 1; ++i)
    ans[a[i].second] = 3;
  for (int i = 0; i < n; ++i) cout << ans[i] << ' ';
}
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  solve();
  return 0;
}
