#include <bits/stdc++.h>
using namespace std;
int ans[4], a[10000], b[10000];
int one[10000 + 1], two[10000 + 1], three[10000 + 1];
int n;
bool bz;
bool cmp(int x, int y) { return x > y; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
  sort(b + 1, b + n + 1, cmp);
  for (int i = 1; i < n; i++) {
    if ((n - i) / 2 * 2 < i) break;
    bool bz1 = 0;
    if (bz && b[ans[0]] - b[ans[0] + 1] > b[i] - b[i + 1]) continue;
    if (!bz || b[ans[0]] - b[ans[0] + 1] < b[i] - b[i + 1]) bz1 = 1;
    for (int j = i + (i + 1) / 2; j < n; j++) {
      if (bz && b[ans[1]] - b[ans[1] + 1] > b[j] - b[j + 1] && !bz1) continue;
      bool bz2 = bz1;
      if (!bz || b[ans[1]] - b[ans[1] + 1] < b[j] - b[j + 1]) bz2 = 1;
      if (min(n - j, i) * 2 < max(j - i, i)) break;
      for (int k = j + (max(i, j - i) + 1) / 2; k <= n; k++) {
        if (bz && b[ans[2]] - b[ans[2] + 1] > b[k] - b[k + 1] && !bz2) continue;
        if (!bz || b[ans[1]] - b[ans[1] + 1] < b[k] - b[k + 1]) bz2 = 1;
        if (bz && !bz2 && b[n] == b[k]) break;
        if (min(i, j - i) * 2 < k - j) break;
        ans[0] = i, ans[1] = j, ans[2] = k;
        bz = 1;
        bz1 = bz2 = 0;
      }
    }
  }
  for (int i = 1; i <= ans[0]; i++) one[b[i]]++;
  for (int i = ans[0] + 1; i <= ans[1]; i++) two[b[i]]++;
  for (int i = ans[1] + 1; i <= ans[2]; i++) three[b[i]]++;
  for (int i = 1; i <= n; i++)
    if (one[a[i]]) {
      one[a[i]]--;
      printf("1 ");
    } else if (two[a[i]]) {
      two[a[i]]--;
      printf("2 ");
    } else if (three[a[i]]) {
      three[a[i]]--;
      printf("3 ");
    } else
      printf("-1 ");
  return 0;
}
