#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
const int oo = 1e9;
const int mod = 1e9 + 7;
pair<long long, long long> a[3001];
int n, b[3001], anser[3001];
tuple<int, int, int> ans, id, cur;
int main() {
  ans = make_tuple(-1, -1, -1);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (int i = 1; i < n; i++) b[i] = a[i].first - a[i + 1].first;
  b[n] = a[n].first;
  for (int i = 1; i <= n - 2; i++) {
    for (int j = i + 1; j <= n - 1; j++) {
      int l, r, c1, c2;
      c1 = i;
      c2 = j - i;
      int h = max(c1, c2);
      h++;
      h /= 2;
      l = max(1, h) + j;
      r = min(n - j, 2 * min(c1, c2)) + j;
      if (c1 > 2 * c2 || c2 > 2 * c1 || l > r) continue;
      for (int k = l; k <= r; k++) {
        cur = make_tuple(b[i], b[j], b[k]);
        if (cur > ans) {
          ans = cur;
          id = make_tuple(i, j, k);
        }
      }
    }
  }
  int i1, j1, k1, k;
  i1 = get<0>(id);
  j1 = get<1>(id);
  k1 = get<2>(id);
  for (int i = 1; i <= i1; i++) anser[a[i].second] = 1;
  for (int i = i1 + 1; i <= j1; i++) anser[a[i].second] = 2;
  for (int i = j1 + 1; i <= k1; i++) anser[a[i].second] = 3;
  for (int i = k1 + 1; i <= n; i++) anser[a[i].second] = -1;
  for (int i = 1; i <= n; i++) cout << anser[i] << " ";
  puts("");
}
