#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
int arr[100005];
int n;
int dp[100005][6][6];
vector<int> ans;
int solve(int idx, int prv, int cur) {
  if (idx == n) return dp[idx][prv][cur] = 1;
  if (dp[idx][prv][cur] != -1) return dp[idx][prv][cur];
  bool ret = 0;
  for (int i = 1; i <= 5; i++) {
    if (i == cur) continue;
    if (i < cur && arr[idx] > arr[idx + 1]) ret |= solve(idx + 1, cur, i);
    if (i > cur && arr[idx] < arr[idx + 1]) ret |= solve(idx + 1, cur, i);
    if (arr[idx] == arr[idx + 1]) ret |= solve(idx + 1, cur, i);
  }
  return dp[idx][prv][cur] = ret;
}
void build(int idx, int prv, int cur) {
  if (idx == n) return;
  for (int i = 1; i <= 5; i++) {
    if (dp[idx + 1][cur][i] == 1) {
      ans.push_back(i);
      build(idx + 1, cur, i);
      return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  if (solve(0, 0, 0) == 0) return cout << -1 << '\n', 0;
  build(0, 0, 0);
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
