#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 998244353;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  pair<bool, int> dp[n][5];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 5; j++) {
      dp[i][j].first = false;
      dp[i][j].second = -1;
    }
  }
  for (int j = 0; j < 5; j++) {
    dp[0][j].first = true;
    dp[0][j].second = -1;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 5; j++) {
      if (a[i] == a[i - 1]) {
        for (int k = 0; k < 5; k++) {
          if (!dp[i - 1][k].first || k == j) continue;
          dp[i][j].first = true;
          dp[i][j].second = k;
          break;
        }
      } else if (a[i] < a[i - 1]) {
        for (int k = j + 1; k < 5; k++) {
          if (!dp[i - 1][k].first) continue;
          dp[i][j].first = true;
          dp[i][j].second = k;
          break;
        }
      } else {
        for (int k = 0; k < j; k++) {
          if (!dp[i - 1][k].first) continue;
          dp[i][j].first = true;
          dp[i][j].second = k;
          break;
        }
      }
    }
  }
  vector<int> ans;
  for (int i = 0; i < 5; i++) {
    if (dp[n - 1][i].first) {
      int f = i;
      int indx = n - 1;
      while (f != -1) {
        ans.push_back(f + 1);
        f = dp[indx][f].second;
        indx--;
      }
      break;
    }
  }
  if (ans.size() != n)
    cout << -1;
  else {
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  }
  cout << "\n";
  return 0;
}
