#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
pair<int, int> a[N];
int maxn[N][N], c[N][N];
int ans[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    a[i].second = i;
    scanf("%d", &a[i].first);
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    maxn[i][i] = a[i].first - a[i + 1].first;
    c[i][i] = i;
    for (int j = i + 1; j <= n; j++) {
      if (maxn[i][j - 1] > a[j].first - a[j + 1].first)
        maxn[i][j] = maxn[i][j - 1], c[i][j] = c[i][j - 1];
      else
        maxn[i][j] = a[j].first - a[j + 1].first, c[i][j] = j;
    }
  }
  int first, second, z;
  int mx1 = -0x7fffffff, mx2 = -0x7fffffff, mx3 = -0x7fffffff;
  for (int i = 1; i < n; i++) {
    for (int j = (i + 1) / 2; i + j < n && j <= 2 * i; j++) {
      int l = (max(i, j) + 1) / 2;
      int r = min(n - i - j, min(i, j) * 2);
      if (i + j + l > n) break;
      if (r < l) continue;
      int d1 = a[i].first - a[i + 1].first;
      int d2 = a[i + j].first - a[i + j + 1].first;
      int d3 = maxn[i + j + l][i + j + r];
      if (d1 > mx1 || (d1 == mx1 && d2 > mx2) ||
          (d1 == mx1 && d2 == mx2 && d3 > mx3)) {
        first = i, second = j, z = c[i + j + l][i + j + r];
        mx1 = d1, mx2 = d2, mx3 = d3;
      }
    }
  }
  for (int i = 1; i <= first; i++) ans[a[i].second] = 1;
  for (int i = first + 1; i <= first + second; i++) ans[a[i].second] = 2;
  for (int i = first + second + 1; i <= z; i++) ans[a[i].second] = 3;
  for (int i = z + 1; i <= n; i++) ans[a[i].second] = -1;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
