#include <bits/stdc++.h>
using namespace std;
long long int tmod(long long int x, long long int m) { return (x % m + m) % m; }
bool dp[200000][6];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < 6; i++) dp[0][i] = true;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < 6; j++) {
      if (a[i] > a[i - 1]) {
        for (int k = 1; k < j; k++) {
          dp[i][j] = dp[i][j] | dp[i - 1][k];
        }
      } else if (a[i] == a[i - 1]) {
        for (int k = 1; k < j; k++) {
          dp[i][j] = dp[i][j] | dp[i - 1][k];
        }
        for (int k = j + 1; k < 6; k++) {
          dp[i][j] = dp[i][j] | dp[i - 1][k];
        }
      } else {
        for (int k = j + 1; k < 6; k++) {
          dp[i][j] = dp[i][j] | dp[i - 1][k];
        }
      }
    }
  }
  vector<int> ans;
  for (int j = 1; j < 6; j++) {
    if (dp[n - 1][j] == true) {
      ans.push_back(j);
      break;
    }
  }
  if (ans.size() == 0) {
    cout << -1;
    return 0;
  }
  int pos = n - 1;
  while (ans.size() != n) {
    int i = pos;
    int tempj = ans[ans.size() - 1];
    for (int k = 1; k < 6; k++) {
      if (dp[pos - 1][k] == true) {
        if (a[i] > a[i - 1]) {
          if (tempj > k) {
            ans.push_back(k);
            break;
          }
        } else if (a[i] == a[i - 1]) {
          if (tempj != k) {
            ans.push_back(k);
            break;
          }
        } else {
          if (tempj < k) {
            ans.push_back(k);
            break;
          }
        }
      }
    }
    pos--;
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
