#include <bits/stdc++.h>
using namespace std;
long long int dp[100005][7];
vector<long long int> v;
long long int st[100005][7];
long long int calc(long long int pos, long long int *A, long long int val) {
  if (pos == 0) return 1;
  long long int f = 0, x;
  if (dp[pos][val] != -1) return dp[pos][val];
  for (long long int i = 1; i <= 5; i++) {
    x = 0;
    if (A[pos] < A[pos + 1] && i < val) {
      x = calc(pos - 1, A, i);
    }
    if (A[pos] > A[pos + 1] && i > val) {
      x = calc(pos - 1, A, i);
    }
    if (A[pos] == A[pos + 1] && i != val) {
      x = calc(pos - 1, A, i);
    }
    if (x == 1) {
      f |= x;
      st[pos][val] = i;
    }
  }
  return dp[pos][val] = f;
}
void recons(long long int pos, long long int val) {
  if (pos == 0) return;
  v.push_back(st[pos][val]);
  recons(pos - 1, st[pos][val]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, -1, sizeof(dp));
  long long int n;
  cin >> n;
  long long int A[n + 2];
  A[n + 1] = 100000000000000LL;
  for (long long int i = 1; i <= n; i++) cin >> A[i];
  long long int ans = calc(n, A, 6);
  if (ans == 0)
    cout << -1 << "\n";
  else {
    recons(n, 6);
  }
  reverse(v.begin(), v.end());
  for (auto i : v) cout << i << "\n";
}
