#include <bits/stdc++.h>
using namespace std;
int n, a[100010], dp[100010][10] = {0}, ans[100010] = {0};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= 5; i++) dp[1][i] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= 5; j++) {
      for (int k = 1; k <= 5; k++) {
        if (!dp[i - 1][k]) continue;
        if (a[i] > a[i - 1] && j > k) dp[i][j] = 1;
        if (a[i] < a[i - 1] && j < k) dp[i][j] = 1;
        if (a[i] == a[i - 1] && j != k) dp[i][j] = 1;
      }
    }
  }
  int flag = 0, pre = -1;
  for (int i = 1; i <= 5; i++) {
    if (dp[n][i]) {
      flag = 1;
      pre = i;
      break;
    }
  }
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  ans[n] = pre;
  for (int i = n - 1; i >= 1; i--) {
    int flag = 0;
    for (int j = 1; j <= 5; j++) {
      if (!dp[i][j]) continue;
      if (a[i] < a[i + 1] && j < pre) pre = j, flag = 1;
      if (a[i] > a[i + 1] && j > pre) pre = j, flag = 1;
      if (a[i] == a[i + 1] && j != pre) pre = j, flag = 1;
      if (flag) break;
    }
    ans[i] = pre;
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
