#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<bool>> b;
vector<vector<int>> way;
int findMax(int ind) {
  for (int i = 4; i >= 0; i--) {
    if (b[ind][i]) {
      return i;
    }
  }
  return -1;
}
int findMin(int ind) {
  for (int i = 0; i < 5; i++) {
    if (b[ind][i]) {
      return i;
    }
  }
  return -1;
}
void Xor(int ind) {
  for (int i = 0; i < 5; i++) {
    if (!b[ind][i])
      for (int j = 0; j < 5; j++) {
        if (b[ind - 1][j] && j != i) {
          b[ind][i] = true;
          way[ind][i] = j;
          break;
        }
      }
  }
}
int main() {
  cin >> n;
  way.resize(n, vector<int>(5));
  b.resize(n + 1, vector<bool>(5));
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < 5; i++) b[0][i] = true;
  int k;
  for (int i = 1; i < n; i++) {
    if (a[i] < a[i - 1]) {
      if (findMax(i - 1) == 0) {
        cout << -1;
        return 0;
      } else {
        k = findMax(i - 1);
        for (int j = 0; j < k; j++) {
          if (!b[i][j]) {
            b[i][j] = true;
            way[i][j] = k;
          }
        }
      }
    } else if (a[i] > a[i - 1]) {
      if (findMin(i - 1) == 4) {
        cout << -1;
        return 0;
      } else {
        k = findMin(i - 1);
        for (int j = k + 1; j < 5; j++) {
          if (!b[i][j]) {
            b[i][j] = true;
            way[i][j] = k;
          }
        }
      }
    } else {
      Xor(i);
    }
  }
  list<int> ans;
  int fir;
  for (int j = 0; j < 5; j++) {
    if (b[n - 1][j]) {
      fir = j;
    }
  }
  ans.push_back(fir);
  for (int i = n - 1; i >= 1; i--) {
    ans.push_back(way[i][fir]);
    fir = way[i][fir];
  }
  ans.reverse();
  for (auto x : ans) {
    cout << x + 1 << " ";
  }
  return 0;
}
