#include <bits/stdc++.h>
using namespace std;
int n;
int a[200000 + 5], res[200000 + 5];
bool can = true;
void input() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n;
  a[0] = -1, a[n + 1] = 200000 + 5;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
}
void solve() {
  int idx = 1, ii, id;
  stack<int> inc, dec;
  inc.push(0);
  dec.push(n + 1);
  while (idx != n + 1) {
    ii = inc.top(), id = dec.top();
    if (a[idx] > a[ii]) {
      res[idx] = 0;
      inc.push(idx);
    } else {
      if (a[ii] < a[id]) {
        inc.pop();
        res[ii] = 1;
        dec.push(ii);
        if (a[idx] > a[inc.top()]) {
          inc.push(idx);
          res[idx] = 0;
        } else if (a[idx] < a[id]) {
          dec.push(idx);
          res[idx] = 1;
        }
      } else if (a[idx] < a[id]) {
        dec.push(idx);
        res[idx] = 1;
      } else {
        can = false;
        return;
      }
    }
    idx++;
  }
}
int main() {
  input();
  solve();
  if (can) {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++) cout << res[i] << " ";
  } else
    cout << "NO" << endl;
  return 0;
}
