#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5 + 1;
int arr[N];
int dp[N][6][6][6], build[N][6][6][6];
bool solve(int index, int l, int r, int no) {
  if (index >= n - 1) return 1;
  if (r < l) return 0;
  int &cur = dp[index][l][r][no];
  if (~cur) return cur;
  bool sol = 0;
  int chosenI = 1;
  for (int i = l; i <= r; i++) {
    if (i == no) continue;
    if (arr[index] < arr[index + 1])
      sol |= solve(index + 1, i + 1, 5, 0);
    else if (arr[index] > arr[index + 1])
      sol |= solve(index + 1, 1, i - 1, 0);
    else
      sol |= solve(index + 1, 1, 5, i);
    if (sol) {
      chosenI = i;
      break;
    }
  }
  build[index][l][r][no] = chosenI;
  return cur = sol;
}
void testCase() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  memset(dp, -1, sizeof dp);
  bool sol = solve(0, 1, 5, 0);
  if (!sol) {
    cout << -1;
    return;
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    for (int l = 1; l <= 5; l++) {
      for (int r = 1; r <= 5; r++) {
        for (int j = 0; j <= 5; j++) {
          if (dp[i][l][r][j] == 1) ans.push_back(build[i][l][r][j]);
        }
      }
    }
  }
  if (ans.empty()) {
    cout << 1;
    return;
  }
  if (arr[n - 2] < arr[n - 1])
    ans.push_back(ans.back() + 1);
  else if (arr[n - 2] > arr[n - 1])
    ans.push_back(ans.back() - 1);
  else {
    if (ans.back() == 1)
      ans.push_back(2);
    else
      ans.push_back(1);
  }
  if (!ans.back()) {
    int index = n - 1;
    while (ans[index] < ans[index - 1]) ans[index--]++;
  }
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) {
    testCase();
  }
  return 0;
}
