#include <bits/stdc++.h>
using namespace std;
const int impossible = -1;
int main() {
  int size;
  cin >> size;
  vector<pair<int, int>> student(size);
  for (int i = 0; i < size; i++) {
    cin >> student[i].first;
    student[i].second = i;
  }
  sort(student.begin(), student.end(), greater<pair<int, int>>());
  vector<vector<pair<int, int>>> largest_gap(
      student.size(), vector<pair<int, int>>(
                          student.size(), make_pair(impossible, impossible)));
  for (int r = 0; r < student.size(); r++)
    for (int i = 0; i + r < student.size(); i++)
      if (r == 0) {
        if (i + 1 < student.size())
          largest_gap[i][i].first = student[i].first - student[i + 1].first;
        else
          largest_gap[i][i].first = student[i].first;
        largest_gap[i][i].second = i;
      } else {
        if (largest_gap[i][i].first > largest_gap[i + 1][i + r].first) {
          largest_gap[i][i + r].first = largest_gap[i][i].first;
          largest_gap[i][i + r].second = i;
        } else {
          largest_gap[i][i + r].first = largest_gap[i + 1][i + r].first;
          largest_gap[i][i + r].second = largest_gap[i + 1][i + r].second;
        }
      }
  vector<vector<pair<int, int>>> bronze_gap(
      student.size(), vector<pair<int, int>>(
                          student.size(), make_pair(impossible, impossible)));
  for (int i = 0; i < student.size(); i++)
    for (int small = 1; small < student.size(); small++) {
      int large = i - small;
      if (small > large) continue;
      int left = student.size() - i;
      int lowest = max(1, (large + 1) / 2);
      if (left < lowest) continue;
      int highest = min(2 * small, left);
      if (highest < lowest) continue;
      int begin = i + lowest, end = i + highest;
      bronze_gap[i][small].first = largest_gap[begin - 1][end - 1].first;
      bronze_gap[i][small].second = largest_gap[begin - 1][end - 1].second + 1;
    }
  vector<pair<vector<int>, int>> silver_gap(
      student.size(), make_pair(vector<int>(), impossible));
  for (int i = 1; i < student.size(); i++) {
    int left = student.size() - i;
    int lowest = (i + 1) / 2;
    if (left < lowest) continue;
    int highest = min(2 * i, left);
    if (highest < lowest) continue;
    int begin = i + lowest, end = i + highest;
    vector<int> best(2, impossible);
    for (int next = begin; next <= end && next < student.size(); next++) {
      vector<int> now(2);
      now[0] = largest_gap[next - 1][next - 1].first;
      now[1] = bronze_gap[next][min(i, next - i)].first;
      if (now[1] == impossible) continue;
      if (now > best) {
        silver_gap[i].first = best = now;
        silver_gap[i].second = next;
      }
      begin = next + 1;
    }
  }
  vector<int> best(4, impossible);
  for (int i = 1; i < student.size(); i++) {
    if (silver_gap[i].second == impossible) continue;
    vector<int> now = silver_gap[i].first;
    now.insert(now.begin(), largest_gap[i - 1][i - 1].first);
    now.push_back(i);
    if (now > best) best = now;
  }
  int golds = best.back();
  int silvers = silver_gap[golds].second;
  int bronzes = bronze_gap[silvers][min(golds, silvers - golds)].second;
  vector<int> place(student.size(), -1);
  for (int i = 0; i < golds; i++) place[student[i].second] = 1;
  for (int i = golds; i < silvers; i++) place[student[i].second] = 2;
  for (int i = silvers; i < bronzes; i++) place[student[i].second] = 3;
  for (int i = 0; i < place.size(); i++) cout << place[i] << ' ';
  cout << '\n';
}
