#include <bits/stdc++.h>
using namespace std;
int arr[100005], ans[100005], n, up = 1, down = 1, cnt1, cnt2, last;
bool nott;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (i) {
      if (arr[i] > arr[i - 1])
        up++, down = 1;
      else if (arr[i] < arr[i - 1])
        down++, up = 1;
      else
        up = 1, down = 1;
      if (up == 5 || down == 5) {
        cnt1 = 1, cnt2 = 1;
        for (int y = i - 5; y >= max(0, i - 9); y--) {
          if (y == i - 5 && arr[y] != arr[y + 1])
            break;
          else {
            if (arr[y] < arr[y + 1])
              cnt1++;
            else if (arr[y] > arr[y + 1])
              cnt2++;
          }
        }
      }
      if (up > 5 || down > 5 || (cnt1 == 5 && down == 5) ||
          (cnt2 == 5 && up == 5))
        nott = 1;
    }
  }
  if (!nott) {
    if (arr[1] > arr[0])
      ans[0] = 1;
    else if (arr[1] < arr[0])
      ans[0] = 5;
    else
      ans[0] = 2;
    for (int i = 1; i < n; i++) {
      if (arr[i] < arr[i + 1]) {
        if (arr[i] <= arr[i - 1]) {
          if (ans[i - 1] == 1)
            ans[i] = 2;
          else
            ans[i] = 1;
        } else
          ans[i] = ans[i - 1] + 1;
      } else if (arr[i] > arr[i + 1]) {
        if (arr[i] >= arr[i - 1]) {
          if (ans[i - 1] == 5)
            ans[i] = 4;
          else
            ans[i] = 5;
        } else
          ans[i] = ans[i - 1] - 1;
      } else {
        if (arr[i - 1] > arr[i])
          ans[i] = ans[i - 1] - 1;
        else if (arr[i - 1] < arr[i])
          ans[i] = ans[i - 1] + 1;
        else {
          if (ans[i - 1] == 2)
            ans[i] = 3;
          else
            ans[i] = 2;
        }
      }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
  } else
    cout << -1 << endl;
  return 0;
}
