#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) {
    cin >> i;
  }
  vector<vector<bool>> dp(n, vector<bool>(5));
  for (int last_val = 0; last_val < 5; ++last_val) {
    dp[0][last_val] = true;
  }
  vector<vector<int>> pr(n, vector<int>(5));
  for (int i = 0; i < 5; ++i) {
    pr[0][i] = -1;
  }
  for (int pref = 1; pref < n; ++pref) {
    for (int last_val = 0; last_val < 5; ++last_val) {
      dp[pref][last_val] = false;
      if (a[pref - 1] < a[pref]) {
        for (int prev_val = 0; prev_val < last_val; ++prev_val) {
          if (dp[pref - 1][prev_val]) {
            dp[pref][last_val] = true;
            pr[pref][last_val] = prev_val;
            break;
          }
        }
      } else if (a[pref - 1] == a[pref]) {
        for (int prev_val = 0; prev_val < 5; ++prev_val) {
          if (prev_val == last_val) {
            continue;
          }
          if (dp[pref - 1][prev_val]) {
            dp[pref][last_val] = true;
            pr[pref][last_val] = prev_val;
            break;
          }
        }
      } else {
        for (int prev_val = last_val + 1; prev_val < 5; ++prev_val) {
          if (dp[pref - 1][prev_val]) {
            dp[pref][last_val] = true;
            pr[pref][last_val] = prev_val;
            break;
          }
        }
      }
    }
  }
  int id = -1;
  for (int i = 0; i < 5; ++i) {
    if (dp[n - 1][i]) {
      id = i;
      break;
    }
  }
  if (id == -1) {
    cout << -1 << '\n';
  } else {
    vector<int> path;
    for (int i = id, step = n - 1; step >= 0; i = pr[step][i], --step) {
      path.emplace_back(i);
    }
    for (int i = n - 1; i >= 0; --i) {
      cout << ' ' << path[i] + 1;
    }
    cout << '\n';
  }
  return 0;
}
