#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int a[N], Log[N], ra[N], b[N], st[N][20], n, output[N];
struct node {
  int a, b, c, i, j, k;
  node(int a = -1, int b = -1, int c = -1, int i = -1, int j = -1, int k = -1)
      : a(a), b(b), c(c), i(i), j(j), k(k){};
  bool operator<(const node& x) const {
    if (a == x.a)
      if (b == x.b)
        return c < x.c;
      else
        return b < x.b;
    else
      return a < x.a;
  }
} ans;
void getlog() {
  Log[1] = 0;
  for (int i = 2; i < N; i++) Log[i] = Log[i / 2] + 1;
  return;
}
void rmq() {
  for (int i = 0; i < n; i++) st[i][0] = i;
  for (int i = 1; (1 << i) <= n; i++)
    for (int j = 0; j + (1 << i) <= n; j++)
      if (b[st[j][i - 1]] < b[st[j + (1 << (i - 1))][i - 1]])
        st[j][i] = st[j + (1 << (i - 1))][i - 1];
      else
        st[j][i] = st[j][i - 1];
  return;
}
int query(int l, int r) {
  int k = Log[r - l + 1];
  if (b[st[l][k]] < b[st[r - (1 << k) + 1][k]])
    return st[r - (1 << k) + 1][k];
  else
    return st[l][k];
}
bool cmp(int x, int y) { return a[x] > a[y]; }
void slove() {
  for (int i = 0; i < n; i++) ra[i] = i;
  sort(ra, ra + n, cmp);
  for (int i = 0; i < n - 1; i++) b[i] = a[ra[i]] - a[ra[i + 1]];
  b[n - 1] = a[ra[n - 1]];
  rmq();
  for (int i = 0; i < n / 2; i++)
    for (int j = i / 2; j <= 2 * i + 1 && i + j + 2 < n; j++) {
      int l = i + j + 2 + max(i, j) / 2,
          r = min(i + j + 3 + min(i, j) * 2, n - 1);
      if (l > r) continue;
      int k = query(l, r);
      ans = max(ans, node(b[i], b[j + i + 1], b[k], i, j + i + 1, k));
    }
  return;
}
int main() {
  cin >> n;
  getlog();
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  slove();
  int i = 0;
  for (; i <= ans.i; i++) output[ra[i]] = 1;
  for (; i <= ans.j; i++) output[ra[i]] = 2;
  for (; i <= ans.k; i++) output[ra[i]] = 3;
  for (; i < n; i++) output[ra[i]] = -1;
  for (int i = 0; i < n; i++) printf("%d%c", output[i], (i == n - 1) ? 10 : 32);
  return 0;
}
