#include <bits/stdc++.h>
using namespace std;
const long long INF = 99999999;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  vector<int> a(n);
  ;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  ;
  vector<int> c;
  for (int j = 1; j < n; ++j) {
    if (a[j] > a[j - 1])
      c.push_back(1);
    else if (a[j] < a[j - 1])
      c.push_back(-1);
    else
      c.push_back(0);
  }
  vector<pair<int, int>> d;
  int p = 1;
  for (int k = 1; k < c.size(); ++k) {
    if (c[k] == c[k - 1])
      p++;
    else {
      d.push_back({p, c[k - 1]});
      p = 1;
    }
  }
  d.push_back({p, c[c.size() - 1]});
  vector<int> answ;
  if (d[0].second == 0)
    answ.push_back(3);
  else if (d[0].second == -1)
    answ.push_back(5);
  else
    answ.push_back(1);
  int last = 0;
  for (int i = 0; i < d.size(); ++i) {
    int cnt = d[i].first;
    int type = d[i].second;
    if (type == 0) {
      bool f = answ[last] == 3;
      for (int j = 0; j < cnt - 1; ++j) {
        if (f)
          answ.push_back(4);
        else
          answ.push_back(3);
        f = !f;
        last++;
      }
      if (i + 1 < d.size() && d[i + 1].second == -1) {
        if (answ[last] == 5)
          answ.push_back(4);
        else
          answ.push_back(5);
        last++;
      } else if (i + 1 < d.size() && d[i + 1].second == 1) {
        if (answ[last] == 1)
          answ.push_back(2);
        else
          answ.push_back(1);
        last++;
      } else {
        if (answ[last] == 4)
          answ.push_back(3);
        else
          answ.push_back(4);
        last++;
      }
    } else {
      for (int j = 0; j < cnt - 1; ++j) {
        answ.push_back(answ[last] + type);
        last++;
      }
      if (answ[last] > 5 || answ[last] < 1) {
        cout << -1;
        return 0;
      }
      if (i + 1 < d.size() && d[i + 1].second == -1) {
        if (answ[last] == 5) {
          cout << -1;
          return 0;
        }
        answ.push_back(5);
        last++;
      } else if (i + 1 < d.size() && d[i + 1].second == 1) {
        if (answ[last] == 1) {
          cout << -1;
          return 0;
        }
        answ.push_back(1);
        last++;
      } else {
        answ.push_back(answ[last] + type);
        last++;
        if (answ[last] > 5 || answ[last] < 1) {
          cout << -1;
          return 0;
        }
      }
    }
  }
  for (int l = 0; l < n; ++l) {
    cout << answ[l] << " ";
  }
}
