#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
struct Node {
  int id;
  int a;
} s[5010];
int delta[5210], res[5110];
int f[5010][20];
std::vector<std::pair<int, int> > vec;
int query(int l, int r) {
  int lg = log2(r - l + 1);
  return ((delta[f[l][lg]] > delta[f[r - (1 << lg) + 1][lg]])
              ? f[l][lg]
              : f[r - (1 << lg) + 1][lg]);
}
bool cmp(Node a, Node b) { return a.a > b.a; }
int main() {
  int n = inp();
  for (int i = 1; i <= n; i++) {
    s[i].a = inp();
    s[i].id = i;
  }
  std::sort(s + 1, s + n + 1, cmp);
  s[n + 1].a = 0;
  for (int i = 2; i <= n + 1; i++) delta[i - 1] = s[i - 1].a - s[i].a;
  for (int i = 1; i <= n; i++) f[i][0] = i;
  for (int j = 1; j <= 15; j++)
    for (int i = 1; i <= n; i++)
      if (i + (1 << j) - 1 <= n)
        f[i][j] = ((delta[f[i][j - 1]] > delta[f[i + (1 << (j - 1))][j - 1]])
                       ? f[i][j - 1]
                       : f[i + (1 << (j - 1))][j - 1]);
  int ans1, ans2;
  int max1 = -1, max2 = 0;
  for (int i = 1; i <= (n >> 1); i++)
    for (int j = (i + 1) >> 1;
         j <= (i << 1) && ((n - i - j) << 1) >= std::max(i, j); j++) {
      int l1 = delta[i];
      int l2 = delta[i + j];
      if (l1 > max1) {
        max1 = l1;
        max2 = l2;
        vec.clear();
        vec.push_back(std::make_pair(i, j));
      } else if (l1 == max1) {
        if (l2 > max2) {
          max2 = l2;
          vec.clear();
          vec.push_back(std::make_pair(i, j));
        } else if (l2 == max2)
          vec.push_back(std::make_pair(i, j));
      }
    }
  int ans3;
  int max = -1;
  for (int i = 0; i < vec.size(); i++) {
    int l1 = vec[i].first;
    int l2 = vec[i].second;
    int minl = std::max((std::max(l1, l2) + 1) >> 1, 1);
    int maxl = std::min(l1, l2) << 1;
    if (minl > maxl || l1 + l2 + minl > n) continue;
    int lb = l1 + l2 + minl;
    int rb = std::min(l1 + l2 + maxl, n);
    int pos = query(lb, rb);
    if (delta[pos] > max) {
      max = delta[pos];
      ans3 = pos - l1 - l2;
      ans1 = l1;
      ans2 = l2;
    }
  }
  memset(res, -1, sizeof(res));
  for (int i = 1; i <= ans1; i++) res[s[i].id] = 1;
  for (int i = ans1 + 1; i <= ans1 + ans2; i++) res[s[i].id] = 2;
  for (int i = ans1 + ans2 + 1; i <= ans1 + ans2 + ans3; i++) res[s[i].id] = 3;
  for (int i = 1; i <= n; i++) printf("%d ", res[i]);
  putchar('\n');
}
