#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int N = (int)1e6 + 7;
int n;
int a[N], b[N];
bool vis[N][10];
void Init() {
  memset(vis, 0, sizeof(vis));
  a[0] = INF;
  for (int i = (1); i < (n + 1); ++i) scanf("%d", a + i);
}
bool dfs(int i, int pre) {
  if (i == n + 1) return true;
  if (vis[i][pre]) return false;
  vis[i][pre] = 1;
  for (int cur = (1); cur < (6); ++cur) {
    if (a[i] < a[i - 1] && cur < pre) {
      b[i] = cur;
      if (dfs(i + 1, cur)) return true;
    }
    if (a[i] > a[i - 1] && cur > pre) {
      b[i] = cur;
      if (dfs(i + 1, cur)) return true;
    }
    if (a[i] == a[i - 1] && cur != pre) {
      b[i] = cur;
      if (dfs(i + 1, cur)) return true;
    }
  }
  return false;
}
int Solve() {
  if (dfs(1, 6)) {
    for (int i = (1); i < (n + 1); ++i) printf("%d%c", b[i], " \n"[i == n]);
  } else {
    puts("-1");
  }
  return 0;
}
int main() {
  while (~scanf("%d", &n)) {
    Init();
    Solve();
  }
  return 0;
}
