#include <bits/stdc++.h>
int N;
std::pair<int, int> arr[3000];
int ans[3000];
int main() {
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> arr[i].first;
    arr[i].second = i;
  }
  std::sort(arr, arr + N, std::greater<std::pair<int, int> >());
  std::pair<std::pair<int, int>, int> h = {{-1, -1}, -1}, p;
  for (int i = 0; i < N; i++) {
    for (int j = std::max((i + 2) >> 1, 1) + i;
         j <= std::min(2 * (i + 1) + i, N - 1); j++) {
      for (int k = std::max(1, std::max((i + 2) >> 1, (j - i + 1) >> 1)) + j;
           k <= std::min(std::min(2 * (i + 1), 2 * (j - i)) + j, N - 1); k++) {
        std::pair<std::pair<int, int>, int> tmp = {
            {arr[i].first - arr[i + 1].first, arr[j].first - arr[j + 1].first},
            ((k == N - 1) ? arr[k].first : (arr[k].first - arr[k + 1].first))};
        if (tmp > h) {
          h = tmp;
          p = {{i, j}, k};
        }
      }
    }
  }
  for (int i = 0; i <= p.first.first; i++) ans[arr[i].second] = 1;
  for (int i = p.first.first + 1; i <= p.first.second; i++)
    ans[arr[i].second] = 2;
  for (int i = p.first.second + 1; i <= p.second; i++) ans[arr[i].second] = 3;
  for (int i = p.second + 1; i < N; i++) ans[arr[i].second] = -1;
  for (int i = 0; i < N; i++) std::cout << ans[i] << " ";
  std::cout << "\n";
  return 0;
}
