#include <bits/stdc++.h>
using namespace std;
struct fastIO {
  fastIO() { ios_base::sync_with_stdio(0); }
};
const int MAXN = 1e6 * 2;
long long n, a[MAXN], d[MAXN][11], b[MAXN];
int main() {
  fastIO();
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = (1); i < (n); i++) {
    for (long long j = (0); j < (5); j++) {
      d[i][j] = -1;
      if (a[i] == a[i - 1]) {
        for (int k = 0; k < 5; k++) {
          if (k != j && d[i - 1][k] != -1) {
            d[i][j] = k;
          }
        }
      }
      if (a[i] > a[i - 1]) {
        for (int k = j - 1; k >= 0; k--) {
          if (d[i - 1][k] != -1) {
            d[i][j] = k;
          }
        }
      }
      if (a[i] < a[i - 1]) {
        for (int k = j + 1; k < 5; k++) {
          if (d[i - 1][k] != -1) {
            d[i][j] = k;
          }
        }
      }
    }
  }
  for (long long i = (0); i < (5); i++) {
    if (d[n - 1][i] != -1) {
      for (int j = n - 1; j >= 0; j--) {
        b[j] = i;
        i = d[j][i];
      }
      for (long long i = 0; i < n; i++) {
        cout << b[i] + 1 << ' ';
      }
      exit(0);
    }
  }
  cout << -1;
  return 0;
}
