#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  const int SIZE = 1e5;
  static int n, arr[SIZE], par[SIZE][5], curr;
  static bool dp[SIZE][5];
  vector<int> ans;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < 5; i++) dp[0][i] = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] > arr[i - 1]) {
      dp[i][0] = 0;
      for (int j = 1; j < 5; j++) {
        for (int k = 0; k < j; k++)
          if (dp[i - 1][k]) {
            dp[i][j] = 1;
            par[i][j] = k;
            break;
          }
      }
    }
    if (arr[i] < arr[i - 1]) {
      dp[i][4] = 0;
      for (int j = 0; j < 4; j++) {
        for (int k = j + 1; k < 5; k++)
          if (dp[i - 1][k]) {
            dp[i][j] = 1;
            par[i][j] = k;
            break;
          }
      }
    }
    if (arr[i] == arr[i - 1]) {
      for (int j = 0; j < 5; j++) {
        for (int k = 0; k < 5; k++)
          if (j != k && dp[i - 1][k]) {
            dp[i][j] = 1;
            par[i][j] = k;
            break;
          }
      }
    }
  }
  for (int i = 0; i < 5; i++)
    if (dp[n - 1][i]) {
      curr = i;
      for (int j = n - 1; j > 0; j--) {
        ans.push_back(curr + 1);
        curr = par[j][curr];
      }
      ans.push_back(curr + 1);
      for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i] << ' ';
      return 0;
    }
  cout << -1;
}
