#include <bits/stdc++.h>
using namespace std;
const int limite = 3005;
int n;
pair<int, int> a[limite];
int sol[limite];
int sold1c2 = -1;
int sold2c3 = -1;
int sold3c4 = -1;
int sollen1;
int sollen2;
int sollen3;
pair<int, int> maximoentre[limite][limite];
bool mejor(int d1c2, int d2c3, int d3c4) {
  if (d1c2 != sold1c2) return d1c2 > sold1c2;
  if (d2c3 != sold2c3) return d2c3 > sold2c3;
  return d3c4 > sold3c4;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 0; i < n; i++) {
    maximoentre[i][i] = pair<int, int>(a[i].first - a[i + 1].first, i);
    for (int j = i + 1; j < n; j++) {
      maximoentre[i][j] = max(maximoentre[i][j - 1],
                              pair<int, int>(a[j].first - a[j + 1].first, j));
    }
  }
  for (int len1 = 1; len1 <= n - 2; len1++) {
    for (int len2 = len1 + 1; len2 <= n - 1; len2++) {
      if (2 * len1 < len2 - len1 or 2 * (len2 - len1) < len1) continue;
      int d1c2 = a[len1 - 1].first - a[len1].first;
      int d2c3 = a[len2 - 1].first - a[len2].first;
      int len3min = len2 + max(len1, len2 - len1) / 2;
      while (2 * (len3min - len2) < max(len1, len2 - len1)) len3min++;
      int len3max = min(n, len2 + min(len1, len2 - len1) * 2);
      if (len3min > len3max) continue;
      pair<int, int> p = maximoentre[len3min - 1][len3max - 1];
      int d3c4 = p.first;
      int len3 = p.second + 1;
      if (mejor(d1c2, d2c3, d3c4)) {
        sold1c2 = d1c2;
        sold2c3 = d2c3;
        sold3c4 = d3c4;
        sollen1 = len1;
        sollen2 = len2;
        sollen3 = len3;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int &x = sol[a[i].second];
    if (i < sollen1)
      x = 1;
    else if (i < sollen2)
      x = 2;
    else if (i < sollen3)
      x = 3;
    else
      x = -1;
  }
  for (int i = 1; i <= n; i++) {
    if (i > 1) cout << " ";
    cout << sol[i];
  }
  cout << endl;
}
