#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 10;
int n;
int a[maxn];
pair<int, int> p[maxn];
int ans[] = {INT_MIN, INT_MIN, INT_MIN};
int cut[3];
int b[maxn];
inline bool check(int x, int y, int z) {
  return x > 0 && y > 0 && z > 0 && x <= 2 * min(y, z) && y <= 2 * min(x, z) &&
         z <= 2 * min(x, y);
}
pair<int, int> dp[maxn][maxn];
inline void solve() {
  for (int i = 1; i <= n; ++i) p[i] = {a[i], i};
  sort(p + 1, p + 1 + n);
  reverse(p + 1, p + 1 + n);
  int d[3];
  for (int i = 1; i <= n; ++i) {
    dp[i][i] = {p[i].first - p[i + 1].first, i};
    for (int j = i + 1; j <= n; ++j)
      dp[i][j] = max(dp[i][j - 1], {p[j].first - p[j + 1].first, j});
  }
  for (int x = 1; x < n; ++x) {
    d[0] = p[x].first - p[x + 1].first;
    for (int y = x + 1; y < n; ++y) {
      d[1] = p[y].first - p[y + 1].first;
      if (max(x, y - x) > 2 * min(x, y - x)) continue;
      int L = y + max(1, (max(x, y - x) + 1) / 2);
      int R = y + min(n - y, 2 * min(x, y - x));
      if (L <= R) {
        d[2] = dp[L][R].first;
        if ((d[0] > ans[0]) || (d[0] == ans[0] && d[1] > ans[1]) ||
            (d[0] == ans[0] && d[1] == ans[1] && d[2] > ans[2])) {
          for (int k = 0; k < 3; ++k) ans[k] = d[k];
          cut[0] = x;
          cut[1] = y;
          cut[2] = dp[L][R].second;
        }
      }
    }
  }
  for (int i = 1; i <= cut[0]; ++i) b[p[i].second] = 1;
  for (int i = cut[0] + 1; i <= cut[1]; ++i) b[p[i].second] = 2;
  for (int i = cut[1] + 1; i <= cut[2]; ++i) b[p[i].second] = 3;
  for (int i = cut[2] + 1; i <= n; ++i) b[p[i].second] = -1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  solve();
  for (int i = 1; i <= n; ++i) printf("%d ", b[i]);
  printf("\n");
  return 0;
}
