#include <bits/stdc++.h>
using namespace std;
double eps = 1e-7;
signed main() {
  long long n;
  cin >> n;
  vector<long long> arr;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (arr.size() > 1) {
      if (arr[arr.size() - 1] == arr[arr.size() - 2] &&
          arr[arr.size() - 1] == a) {
      }
    }
    arr.push_back(a);
  }
  n = arr.size();
  vector<vector<bool>> d(n, vector<bool>(5, 0));
  vector<vector<long long>> p(n, vector<long long>(5, -1));
  d[0][0] = 1;
  d[0][1] = 1;
  d[0][2] = 1;
  d[0][3] = 1;
  d[0][4] = 1;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < 5; j++) {
      if (arr[i] > arr[i - 1]) {
        for (long long k = 0; k < j; k++) {
          if (d[i - 1][k]) {
            p[i][j] = k;
          }
          d[i][j] = d[i][j] || d[i - 1][k];
        }
      }
      if (arr[i] == arr[i - 1]) {
        for (long long k = 0; k < 5; k++) {
          if (k == j) {
            continue;
          }
          if (d[i - 1][k]) {
            p[i][j] = k;
          }
          d[i][j] = d[i][j] || d[i - 1][k];
        }
      }
      if (arr[i] < arr[i - 1]) {
        for (long long k = j + 1; k < 5; k++) {
          if (d[i - 1][k]) {
            p[i][j] = k;
          }
          d[i][j] = d[i][j] || d[i - 1][k];
        }
      }
    }
  }
  long long ind = n - 1;
  vector<bool> can(5, 1);
  vector<long long> ans;
  long long now = -1;
  for (long long i = 0; i < 5; i++) {
    if (d[ind][i]) {
      now = i;
    }
  }
  if (now == -1) {
    cout << -1;
    return 0;
  }
  while (ind >= 0) {
    ans.push_back(now);
    now = p[ind][now];
    ind--;
  }
  reverse(ans.begin(), ans.end());
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << " ";
  }
  return 0;
}
