#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn], b[maxn];
int vis[maxn][6];
void dfs(int i, int l) {
  if (i > n) {
    for (int i = 1; i <= n; i++) printf("%d ", b[i]);
    exit(0);
  }
  if (vis[i][l]) return;
  vis[i][l] = 1;
  for (int f = 1; f <= 5; f++) {
    if (a[i - 1] < a[i] && l < f) {
      b[i] = f;
      dfs(i + 1, f);
    }
    if (a[i - 1] > a[i] && l > f) {
      b[i] = f;
      dfs(i + 1, f);
    }
    if (a[i - 1] == a[i] && f != l) {
      b[i] = f;
      dfs(i + 1, f);
    }
  }
}
int main() {
  scanf("%d", &n);
  a[0] = maxn;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dfs(1, 5);
  printf("-1\n");
}
