#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  stack<int> inc, dec;
  inc.push(-1);
  dec.push(200001);
  vector<int> v;
  if (a[1] < a[0]) {
    dec.push(a[0]);
    v.push_back(1);
  } else {
    inc.push(a[0]);
    v.push_back(0);
  }
  for (i = 1; i < n; i++) {
    if (a[i] > inc.top() && a[i] < dec.top()) {
      if (a[i + 1] > a[i]) {
        inc.push(a[i]);
        v.push_back(0);
      } else {
        dec.push(a[i]);
        v.push_back(1);
      }
    } else if (a[i] > inc.top()) {
      inc.push(a[i]);
      v.push_back(0);
    } else if (a[i] < dec.top()) {
      dec.push(a[i]);
      v.push_back(1);
    } else {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  return 0;
}
