#include <bits/stdc++.h>
using namespace std;
long long solve(long long i, long long prev, long long n, long long a[],
                vector<vector<long long>> &dp) {
  if (i >= n) {
    return dp[i][prev] = 1;
  }
  if (dp[i][prev] != -1) {
    return dp[i][prev];
  }
  long long j;
  if (prev == 0) {
    for (j = 1; j <= 5; j++) {
      if (solve(i + 1, j, n, a, dp) == 1) {
        return dp[i][prev] = 1;
      }
    }
  }
  if (a[i] < a[i - 1]) {
    for (j = 1; j < prev; j++) {
      if (solve(i + 1, j, n, a, dp) == 1) {
        return dp[i][prev] = 1;
      }
    }
  } else if (a[i] > a[i - 1]) {
    for (j = prev + 1; j <= 5; j++) {
      if (solve(i + 1, j, n, a, dp) == 1) {
        return dp[i][prev] = 1;
      }
    }
  } else {
    for (j = 1; j <= 5; j++) {
      if (j != prev && solve(i + 1, j, n, a, dp) == 1) {
        return dp[i][prev] = 1;
      }
    }
  }
  return dp[i][prev] = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, i, j, k, tes, x, ans, m, l, r, c, rem, flag, d, prev, cur,
      tot, pos, u, v;
  t = 1;
  for (tes = 1; tes <= t; tes++) {
    cin >> n;
    long long a[n];
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<vector<long long>> dp(n + 1, vector<long long>(6, -1));
    x = solve(0, 0, n, a, dp);
    if (x) {
      for (i = 1; i <= n; i++) {
        for (j = 1; j <= 5; j++) {
          if (dp[i][j] == 1) {
            cout << j << " ";
            break;
          }
        }
      }
    } else {
      cout << "-1";
    }
  }
  return 0;
}
