#include <bits/stdc++.h>
using namespace std;
void yes() { cout << "YES" << endl; }
void no() {
  cout << "NO" << endl;
  exit(0);
}
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> ans(n, -1);
  const long long INF = 1e18;
  long long inc = -INF, dec = INF;
  auto appendToInc = [&](long long i) {
    ans[i] = 0;
    inc = a[i];
  };
  auto appendToDec = [&](long long i) {
    ans[i] = 1;
    dec = a[i];
  };
  for (long long i = 0; i < n; i++) {
    if (a[i] <= inc && a[i] >= dec) no();
    if (a[i] > inc && a[i] >= dec) {
      appendToInc(i);
      continue;
    }
    if (a[i] <= inc && a[i] < dec) {
      appendToDec(i);
      continue;
    }
    if (i == n - 1) {
      appendToInc(i);
      break;
    }
    if (a[i] < a[i + 1]) {
      appendToInc(i);
      continue;
    }
    appendToDec(i);
  }
  yes();
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << " \n"[i == n - 1];
  }
}
