#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int data[n];
  for (int i = 0; i < n; i++) cin >> data[i];
  bool dyna[n][5];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 5; j++) dyna[i][j] = false;
  for (int i = 0; i < 5; i++) dyna[0][i] = true;
  for (int i = 1; i < n; i++)
    for (int j = 0; j < 5; j++)
      if (dyna[i - 1][j]) {
        if (data[i] >= data[i - 1])
          for (int k = j + 1; k < 5; k++) dyna[i][k] = true;
        if (data[i] <= data[i - 1])
          for (int k = 0; k < j; k++) dyna[i][k] = true;
      }
  int ans[n];
  ans[n - 1] = -1;
  for (int i = 0; i < 5; i++)
    if (dyna[n - 1][i]) {
      ans[n - 1] = i;
      break;
    }
  if (ans[n - 1] < 0) {
    cout << "-1\n";
    return 0;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (data[i] <= data[i + 1])
      for (int k = 0; k < ans[i + 1]; k++)
        if (dyna[i][k]) {
          ans[i] = k;
          goto next_iter;
        }
    if (data[i] >= data[i + 1])
      for (int k = ans[i + 1] + 1; k < n; k++)
        if (dyna[i][k]) {
          ans[i] = k;
          goto next_iter;
        }
  next_iter:;
  }
  cout << ans[0] + 1;
  for (int i = 1; i < n; i++) cout << ' ' << ans[i] + 1;
  cout << endl;
  return 0;
}
