#include <bits/stdc++.h>
using namespace std;
const int N = 1e5, OO = 0x3f3f3f3f;
int arr[N], dp[N][6], n;
vector<int> vc;
bool solve(int idx, int lst) {
  if (lst > 5 || lst < 1) return 0;
  if (idx == n) return 1;
  int &ret = dp[idx][lst];
  if (~ret) return ret;
  ret = 0;
  if (idx != n - 1 && arr[idx] > arr[idx + 1]) {
    for (int i = 1; i < lst; i++) ret |= solve(idx + 1, i);
  } else if (idx != n - 1 && arr[idx] < arr[idx + 1]) {
    for (int i = lst + 1; i < 6; i++) ret |= solve(idx + 1, i);
  } else {
    for (int i = 1; i < 6; i++) {
      if (lst != i) ret |= solve(idx + 1, i);
    }
  }
  return ret;
}
void print(int idx, int lst) {
  if (idx == n) return;
  if (idx != n - 1 && arr[idx] > arr[idx + 1]) {
    for (int i = 1; i < lst; i++) {
      if (solve(idx, lst) == solve(idx + 1, i)) {
        cout << lst << " ", print(idx + 1, i);
        return;
      }
    }
  } else if (idx != n - 1 && arr[idx] < arr[idx + 1]) {
    for (int i = lst + 1; i < 6; i++) {
      if (solve(idx, lst) == solve(idx + 1, i)) {
        cout << lst << " ", print(idx + 1, i);
        return;
      }
    }
  } else {
    for (int i = 1; i < 6; i++) {
      if (lst != i && solve(idx, lst) == solve(idx + 1, i)) {
        cout << lst << " ", print(idx + 1, i);
        return;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  memset(dp, -1, sizeof(dp));
  bool ans;
  int idx;
  for (int i = 1; i < 6; i++) {
    ans = solve(0, i);
    if (ans) {
      idx = i;
      break;
    }
  }
  if (!ans)
    printf("-1");
  else
    print(0, idx);
}
