#include <bits/stdc++.h>
using namespace std;
int n, dp[3005][3005], ans1, ans2, l1, l2, l3, l4, ans3, b[3005][3005], x, y, z,
    o, ans[3005], xx, yy, zz;
pair<int, int> a[3005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n / 2; ++i) {
    swap(a[i], a[n - i + 1]);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      dp[i][j] = -1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      if (j > i) {
        dp[i][j] = dp[i][j - 1];
        b[i][j] = b[i][j - 1];
      }
      if (a[j].first >= a[j + 1].first)
        dp[i][j] = max(dp[i][j], a[j].first - a[j + 1].first);
      if (a[j].first >= a[j + 1].first &&
          dp[i][j] == a[j].first - a[j + 1].first)
        b[i][j] = j;
    }
  }
  ans1 = 0;
  ans2 = 0;
  ans3 = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      l1 = i;
      l2 = j - i;
      if (l1 * 2 < l2 || l2 * 2 < l1) continue;
      l4 = min(l1, l2);
      l3 = max(l1, l2);
      l4 = l4 * 2;
      l3 = (l3 + 1) / 2;
      l4 = min(l4, n - j);
      if (l3 > l4) continue;
      xx = a[i].first - a[i + 1].first;
      yy = a[j].first - a[j + 1].first;
      zz = dp[j + l3][j + l4];
      l3 = b[j + l3][j + l4];
      if (zz == -1) continue;
      if (xx > ans1 || (xx == ans1 && yy > ans2) ||
          (xx == ans1 && yy == ans2 && zz > ans3)) {
        ans1 = xx;
        ans2 = yy;
        ans3 = zz;
        x = i;
        y = j;
        z = l3;
      }
    }
  }
  for (int i = 1; i <= x; ++i) {
    ans[a[i].second] = 1;
  }
  for (int i = x + 1; i <= y; ++i) {
    ans[a[i].second] = 2;
  }
  for (int i = y + 1; i <= z; ++i) {
    ans[a[i].second] = 3;
  }
  for (int i = 1; i <= n; ++i) {
    if (ans[i] == 0) ans[i] = -1;
    cout << ans[i] << " ";
  }
}
