#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int a[100005];
bool dp[100005][7];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int x = 0;
  dp[1][1] = dp[1][2] = dp[1][3] = dp[1][4] = dp[1][5] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 5; ++j) {
      if (i > 1)
        for (int l = 1; l <= 5; ++l) {
          if (a[i - 1] == a[i] && j != l) dp[i][j] |= dp[i - 1][l];
          if (a[i - 1] < a[i] && l < j) dp[i][j] |= dp[i - 1][l];
          if (a[i - 1] > a[i] && l > j) dp[i][j] |= dp[i - 1][l];
        }
      if (i == n && dp[i][j]) x = j;
    }
  }
  if (!x) return cout << -1, 0;
  int m = n;
  vector<int> ans;
  ans.push_back(x);
  while (m > 1) {
    for (int l = 1; l <= 5; ++l) {
      if (a[m - 1] == a[m] && l != x && dp[m - 1][l]) {
        --m, x = l;
        break;
      }
      if (a[m - 1] < a[m] && l < x && dp[m - 1][l]) {
        --m, x = l;
        break;
      }
      if (a[m - 1] > a[m] && l > x && dp[m - 1][l]) {
        --m, x = l;
        break;
      }
    }
    ans.push_back(x);
  }
  for (int i = int(ans.size()) - 1; i >= 0; --i) cout << ans[i] << ' ';
  return 0;
}
