#include <bits/stdc++.h>
using namespace std;
int maxval[3111][3111];
int ind[3111][3111];
pair<long long, long long> b[3111];
int ans[3111];
int a[3111] = {0};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i].first;
    b[i].second = i;
  }
  sort(b, b + n);
  reverse(b, b + n);
  for (int i = 0; i < n; i++) {
    a[i] = b[i].first;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (i == j) {
        maxval[i][j] = a[i] - a[i + 1];
        ind[i][j] = i;
      } else {
        maxval[i][j] = maxval[i][j - 1];
        ind[i][j] = ind[i][j - 1];
        if (maxval[i][j] <= a[j] - a[j + 1]) {
          maxval[i][j] = a[j] - a[j + 1];
          ind[i][j] = j;
        }
      }
    }
  }
  int max1, max2, max3, max4;
  max1 = -1;
  max2 = -1;
  max3 = -1;
  max4 = -1;
  int b1, b2, b3;
  for (int l1 = 1; l1 <= n; l1++) {
    for (int l2 = 1; l2 <= n; l2++) {
      if (max(l1, l2) <= 2 * min(l1, l2) && l1 + l2 < n) {
        int d1 = a[l1 - 1] - a[l1];
        int d2 = a[l1 + l2 - 1] - a[l1 + l2];
        int d3;
        int startlen = max(1, (max(l1, l2) + 1) / 2);
        int endlen = min(n - (l1 + l2), 2 * min(l1, l2));
        if (startlen <= endlen) {
          int i = l1 + l2 + startlen - 1;
          int j = l1 + l2 + endlen - 1;
          if (i < n && i <= j) {
            d3 = maxval[i][j];
            if (max1 < d1 || (max1 == d1 && max2 < d2) ||
                (max1 == d1 && max2 == d2 && max3 < d3)) {
              max1 = d1;
              max2 = d2;
              max3 = d3;
              b1 = l1;
              b2 = l2;
              b3 = ind[i][j] - (l1 + l2) + 1;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i < b1) {
      ans[b[i].second] = 1;
    } else if (i < b1 + b2) {
      ans[b[i].second] = 2;
    } else if (i < b1 + b2 + b3) {
      ans[b[i].second] = 3;
    } else {
      ans[b[i].second] = -1;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
}
