#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int M = 255;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
int n, m, a[N + 10];
int ans[N + 10];
int dp[N + 10][6];
bool dfs(int p, int v) {
  if (p == n + 1) {
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
    exit(0);
  }
  if (a[p] > a[p - 1]) {
    for (int i = v + 1; i <= 5; i++) {
      if (dp[p][i] == -1) continue;
      ans[p] = i;
      dfs(p + 1, i);
      ans[p] = 0;
      dp[p][i] = -1;
    }
  } else if (a[p] < a[p - 1]) {
    for (int i = 1; i < v; i++) {
      if (dp[p][i] == -1) continue;
      ans[p] = i;
      dfs(p + 1, i);
      ans[p] = 0;
      dp[p][i] = -1;
    }
  } else {
    for (int i = 1; i <= 5; i++) {
      if (i == v) continue;
      if (dp[p][i] == -1) continue;
      ans[p] = i;
      dfs(p + 1, i);
      ans[p] = 0;
      dp[p][i] = -1;
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= 5; i++) {
    ans[1] = i;
    dfs(2, i);
  }
  cout << -1;
  return 0;
}
