#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int flag = 1;
int num[] = {5, 0, 1};
int jud(int x, int y) {
  if (x > y)
    return 1;
  else if (x == y)
    return 0;
  else
    return -1;
}
void resert(int low, int high, int direc) {
  if (low != high) {
    int i;
    b[high] = num[direc + 1];
    for (i = low + 1; i < high - 1; i++) {
      if (b[i - 1] + direc == 0 || b[i - 1] + direc == 6) direc *= -1;
      b[i] = b[i - 1] + direc;
    }
    if (high - 1 != low)
      for (i = 1; i <= 5; i++) {
        if (i != b[high - 2] && i != b[high]) {
          b[high - 1] = i;
          break;
        }
      }
    else if (b[high - 1] == b[high]) {
      b[high] += direc;
    }
  }
}
int main() {
  int i, j, n, direc = 1;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  i = 1;
  while (a[i] == a[1]) i++;
  direc = jud(a[i], a[1]);
  if (i == 2) {
    b[1] = num[direc + 1];
  } else
    b[1] = 2;
  resert(1, i - 1, direc);
  for (; i <= n && flag; i++) {
    if (jud(a[i], a[i - 1]) == direc) {
      b[i] = b[i - 1] + direc;
      if (b[i] == 0 || b[i] == 6) {
        flag = 0;
        cout << "-1";
        break;
      }
    } else if (a[i] == a[i - 1]) {
      j = i;
      while (a[j] == a[j - 1]) j++;
      direc = jud(a[j], a[j - 1]);
      resert(i - 1, j - 1, direc);
      i = j - 1;
    } else {
      direc *= -1;
      if (i > 2) {
        int temp = jud(a[i - 1], a[i - 2]);
        if (temp != direc && temp != 0) b[i - 1] = num[direc + 1];
      }
      b[i] = b[i - 1] + direc;
    }
  }
  for (i = 1; i <= n && flag; i++) {
    cout << b[i];
    if (i != n) cout << " ";
  }
  return 0;
}
