#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma warning(disable : 4996)
const long long N = 100100;
long long TN = 1;
long long n;
long long a[N];
long long us[N];
vector<long long> ans;
vector<set<long long>> verr(N);
void solve() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (i == 1) {
      for (long long j = 1; j <= 5; j++) {
        verr[i].insert(j);
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (a[i] > a[i - 1]) {
      long long cur = *(verr[i - 1].begin());
      for (long long j = cur + 1; j <= 5; j++) {
        verr[i].insert(j);
      }
    } else if (a[i] < a[i - 1]) {
      long long cur = *(verr[i - 1].rbegin());
      for (long long j = 1; j < cur; j++) {
        verr[i].insert(j);
      }
    } else {
      for (auto j : verr[i - 1]) {
        for (long long l = 1; l <= 5; l++) {
          if (j != l) {
            verr[i].insert(l);
          }
        }
      }
    }
    if (!(long long)(verr[i]).size()) {
      cout << "-1"
           << "\n";
      return;
    }
  }
  if (!(long long)(verr[n]).size()) {
    cout << -1 << "\n";
    return;
  }
  long long last = *verr[n].begin();
  ans.push_back(last);
  for (long long i = n - 1; i >= 1; i--) {
    if (a[i] < a[i + 1]) {
      for (long long j = 1; j <= 5; j++) {
        if (j < last) {
          if (verr[i].find(j) != verr[i].end()) {
            ans.push_back(j);
            last = j;
            break;
          }
        }
      }
    } else if (a[i] > a[i + 1]) {
      for (long long j = 1; j <= 5; j++) {
        if (j > last) {
          if (verr[i].find(j) != verr[i].end()) {
            ans.push_back(j);
            last = j;
            break;
          }
        }
      }
    } else if (a[i] == a[i + 1]) {
      for (long long j = 1; j <= 5; j++) {
        if (j != last) {
          if (verr[i].find(j) != verr[i].end()) {
            ans.push_back(j);
            last = ans.back();
            break;
          }
        }
      }
    }
  }
  for (long long i = (long long)(ans).size() - 1; i >= 0; i--) {
    cout << ans[i] << " ";
  }
  return;
}
signed main() {
  while (TN--) solve();
  return 0;
}
