#include <bits/stdc++.h>
using namespace std;
bool dp[100000][5];
int solve(int *a, int n) {
  for (int i = 0; i < 5; i++) dp[0][i] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 5; j++) {
      if (dp[i - 1][j]) {
        if (a[i] > a[i - 1]) {
          for (int k = j + 1; k < 5; k++) dp[i][k] = 1;
        } else if (a[i] < a[i - 1]) {
          for (int k = j - 1; k >= 0; k--) dp[i][k] = 1;
        } else {
          for (int k = 0; k < 5; k++)
            if (k != j) dp[i][k] = 1;
        }
      }
    }
  }
  for (int i = 0; i < 5; i++)
    if (dp[n - 1][i]) return i;
  return -1;
}
void printSol(int *a, int n, int prev, int *b) {
  for (int i = n - 2; i >= 0; i--) {
    if (a[i + 1] > a[i]) {
      for (; prev;) {
        prev--;
        if (dp[i][prev]) {
          b[i] = prev;
          break;
        }
      }
    } else if (a[i + 1] < a[i]) {
      while (1) {
        prev++;
        if (dp[i][prev]) {
          b[i] = prev;
          break;
        }
      }
    } else {
      for (int k = 0; k < 5; k++) {
        if (k != prev && dp[i][k]) {
          b[i] = k;
          prev = k;
          break;
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(dp, 0, sizeof(dp));
  if (b[n - 1] = solve(a, n), b[n - 1] != -1) {
    printSol(a, n, b[n - 1], b);
    for (int i = 0; i < n; i++) cout << b[i] + 1 << " ";
    cout << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
