#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n + 5], ans[n + 5];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int fir1 = 1, fir2 = 1;
  a[n] = 2000000000;
  int cur = 0;
  while (a[cur++] == a[cur])
    ;
  if (cur == 2) {
    ans[0] = 2;
  } else {
    if (a[cur - 1] < a[cur])
      ans[0] = 0;
    else
      ans[0] = 4;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1]) {
      ans[i] = ans[i - 1] + 1;
      if (ans[i] == 5) {
        cout << "-1\n";
        return 0;
      }
      if (a[i] > a[i + 1]) {
        for (int x = 4; x >= 0; x--) {
          if (ans[i - 1] != x) {
            ans[i] = x;
            break;
          }
        }
      }
    } else if (a[i] < a[i - 1]) {
      ans[i] = ans[i - 1] - 1;
      if (ans[i] == -1) {
        cout << "-1\n";
        return 0;
      }
      if (a[i] < a[i + 1]) {
        for (int x = 0; x < 4; x++) {
          if (ans[i - 1] != x) {
            ans[i] = x;
            break;
          }
        }
      }
    } else {
      if (a[i] < a[i + 1]) {
        for (int x = 0; x < 4; x++) {
          if (ans[i - 1] != x) {
            ans[i] = x;
            break;
          }
        }
      } else if (a[i] > a[i + 1]) {
        for (int x = 4; x >= 0; x--) {
          if (ans[i - 1] != x) {
            ans[i] = x;
            break;
          }
        }
      } else {
        for (int x = 1; x <= 3; x++) {
          if (ans[i - 1] != x) {
            ans[i] = x;
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] + 1 << ' ';
  }
}
