#include <bits/stdc++.h>
using namespace std;
const int mxn = 5005;
struct stu {
  int sc;
  int id;
} st[mxn];
int n;
inline bool cmp(stu x, stu y) { return x.sc > y.sc; }
int mx[mxn][mxn];
int ans[mxn];
inline void solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> st[i].sc, st[i].id = i;
  sort(st + 1, st + n + 1, cmp);
  for (int i = 1; i <= n; ++i) {
    mx[i][i] = i;
    int M = st[i].sc - st[i + 1].sc;
    for (int j = i + 1; j <= n; ++j) {
      int t = st[j].sc - st[j + 1].sc;
      if (M < t)
        M = t, mx[i][j] = j;
      else
        mx[i][j] = mx[i][j - 1];
    }
  }
  int nwa = 1, nwb = 2, nwc = 3;
  for (int i = 1; i <= n / 2; ++i) {
    if (st[i].sc - st[i + 1].sc < st[nwa].sc - st[nwa + 1].sc) continue;
    int le = i + (i + 1) / 2, ri = min(i * 3, n - (i + 1) / 2);
    for (int j = le; j <= ri; ++j) {
      int lk = j + max((i + 1) / 2, (j - i + 1) / 2),
          rk = min(j + min(i * 2, (j - i) * 2), n);
      if (lk > rk) continue;
      int k = mx[lk][rk];
      int va = st[i].sc - st[i + 1].sc, aa = st[nwa].sc - st[nwa + 1].sc;
      if (va != aa) {
        if (va > aa) nwa = i, nwb = j, nwc = k;
        continue;
      }
      int vb = st[j].sc - st[j + 1].sc, ab = st[nwb].sc - st[nwb + 1].sc;
      if (vb != ab) {
        if (vb > ab) nwa = i, nwb = j, nwc = k;
        continue;
      }
      int vc = st[k].sc - st[k + 1].sc, ac = st[nwc].sc - st[nwc + 1].sc;
      if (vc > ac) nwa = i, nwb = j, nwc = k;
    }
  }
  memset(ans, -1, sizeof(ans));
  for (int i = 1; i <= nwa; ++i) ans[st[i].id] = 1;
  for (int i = nwa + 1; i <= nwb; ++i) ans[st[i].id] = 2;
  for (int i = nwb + 1; i <= nwc; ++i) ans[st[i].id] = 3;
  for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int T;
  T = 1;
  for (; T--;) solve();
}
