#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
pair<int, int> a[N];
pair<int, int> dp[N][N];
struct out {
  int l1, l2, l3;
};
int get(int ind) { return a[ind].first - a[ind + 1].first; }
out get_maxi(out a, out b) {
  if (a.l1 == -1) return b;
  if (b.l1 == -1) return a;
  if (get(a.l1) != get(b.l1)) {
    return get(a.l1) < get(b.l1) ? b : a;
  } else if (get(a.l2) != get(b.l2)) {
    return get(a.l2) < get(b.l2) ? b : a;
  } else if (get(a.l3) != get(b.l3)) {
    return get(a.l3) < get(b.l3) ? b : a;
  } else {
    return a;
  }
}
int result[N];
void solve2(int test = 1) {
  int n;
  scanf("%d ", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d ", &a[i].first);
    a[i].second = i;
    result[i] = -1;
  }
  sort(a + 1, a + n + 1, greater<pair<int, int> >());
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      if (i == j) {
        dp[i][j] = {a[i].first - a[i + 1].first, i};
      } else {
        dp[i][j] = max(dp[i][j - 1], {a[j].first - a[j + 1].first, j});
      }
    }
  }
  out ret = {-1, -1, -1};
  for (int l1 = 1; l1 <= n; ++l1) {
    for (int l2 = (l1 + 1) / 2; l1 + l2 <= n; ++l2) {
      if (l2 > l1 * 2) break;
      int mx = max(l1, l2), mini = min(l1, l2);
      int min_len = (mx + 1) / 2, max_len = mini * 2;
      if (l1 + l2 + min_len > n) break;
      max_len = min(max_len, n - l1 - l2);
      if (min_len <= max_len) {
        int l3 = dp[l1 + l2 + min_len][l1 + l2 + max_len].second - l1 - l2;
        ret = get_maxi(ret, {l1, l1 + l2, l1 + l2 + l3});
      }
    }
  }
  assert(ret.l1 != -1);
  for (int i = 1; i <= ret.l3; ++i) {
    result[a[i].second] = 3;
  }
  for (int i = 1; i <= ret.l2; ++i) {
    result[a[i].second] = 2;
  }
  for (int i = 1; i <= ret.l1; ++i) {
    result[a[i].second] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d ", result[i]);
  }
  putchar('\n');
}
void solve() { solve2(); }
int main(void) {
  solve();
  return 0;
}
