#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int n;
  cin >> n;
  vector<int> a;
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  stack<int> in;
  stack<int> dec;
  int flag = 1;
  for (i = 0; i < n; i++) {
    if (in.empty())
      in.push(i);
    else {
      if (a[i] > a[in.top()])
        in.push(i);
      else {
        if (dec.empty() || a[dec.top()] > a[i]) {
          int x = in.top();
          in.pop();
          if ((in.empty() || a[in.top()] < a[i]) &&
              (dec.empty() || a[x] < a[dec.top()])) {
            in.push(i);
            dec.push(x);
          } else {
            if ((!in.empty() && a[in.top()] >= a[i]) &&
                (dec.empty() || a[x] < a[dec.top()])) {
              dec.push(x);
              dec.push(i);
            } else {
              in.push(x);
              dec.push(i);
            }
          }
        } else {
          flag = 0;
          break;
        }
      }
    }
  }
  if (flag) {
    cout << "YES" << endl;
    vector<int> d;
    d.assign(n, 1);
    while (!in.empty()) {
      d[in.top()] = 0;
      in.pop();
    }
    for (i = 0; i < n; i++) cout << d[i] << " ";
    cout << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
