#include <bits/stdc++.h>
using namespace std;
bool getSequence(vector<vector<bool>>& dp, vector<int>& sequence,
                 const vector<int>& a, int n, int index) {
  if (index == n) return true;
  for (int i = 0; i < 5; i++) {
    if (dp[index][i]) {
      bool can = true;
      if (index > 0) {
        int flag = 0;
        if (a[index] > a[index - 1]) flag = 1;
        if (a[index] < a[index - 1]) flag = 2;
        if (flag == 1 && i <= sequence.back())
          can = false;
        else if (flag == 2 && i >= sequence.back())
          can = false;
        else if (flag == 0 && i == sequence.back())
          can = false;
      }
      if (can) {
        sequence.push_back(i);
        if (getSequence(dp, sequence, a, n, index + 1)) {
          return true;
        }
        sequence.pop_back();
      }
    }
  }
  return false;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int>> dp(n, vector<int>(5, -1));
  for (int i = 0; i < 5; i++) dp[0][i] = 0;
  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 < j; k++) {
          if (dp[i - 1][k] >= 0) {
            dp[i][j] = k;
            break;
          }
        }
      } else if (a[i] < a[i - 1]) {
        for (int k = j + 1; k < 5; k++) {
          if (dp[i - 1][k] >= 0) {
            dp[i][j] = k;
            break;
          }
        }
      } else {
        for (int k = 0; k < 5; k++) {
          if (j != k && dp[i - 1][k] >= 0) {
            dp[i][j] = k;
            break;
          }
        }
      }
    }
  }
  int ind = -1;
  vector<int> ans(n);
  for (int i = 0; i < 5; i++) {
    if (dp[n - 1][i] >= 0) {
      ans[n - 1] = i + 1;
      ind = i;
      break;
    }
  }
  if (ind == -1) {
    cout << -1;
  } else {
    for (int i = n - 1; i > 0; i--) {
      ind = dp[i][ind];
      ans[i - 1] = ind + 1;
    }
    for (int i : ans) cout << i << ' ';
  }
}
