#include <bits/stdc++.h>
using namespace std;
int main() {
  long i, j, n, *a, *res, *I, *D, inc = 0, dec = 0;
  bool b = true;
  cin >> n;
  a = new long[n];
  res = new long[n];
  I = new long[n];
  D = new long[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    if (i == 0) {
      if (a[i] < a[i + 1]) {
        res[i] = 0;
        I[inc] = a[i];
        inc++;
      } else {
        res[i] = 1;
        D[dec] = a[i];
        dec++;
      }
    } else if (i == n - 1) {
      if (a[i] > I[inc - 1] || inc == 0) {
        res[i] = 0;
        I[inc] = a[i];
        inc++;
      } else if (a[i] < D[dec - 1] || dec == 0) {
        res[i] = 1;
        D[dec] = a[i];
        dec++;
      } else {
        b = false;
        break;
      }
    } else {
      if ((a[i] > I[inc - 1] || inc == 0) && (a[i] < D[dec - 1] || dec == 0)) {
        if (a[i] < a[i + 1]) {
          res[i] = 0;
          I[inc] = a[i];
          inc++;
        } else if (a[i] > a[i + 1]) {
          res[i] = 1;
          D[dec] = a[i];
          dec++;
        } else {
          res[i] = 0;
          res[i + 1] = 1;
          I[inc] = a[i];
          D[dec] = a[i];
          inc++;
          dec++;
          i++;
        }
      } else if (a[i] > I[inc - 1] || inc == 0) {
        res[i] = 0;
        I[inc] = a[i];
        inc++;
      } else if (a[i] < D[dec - 1] || dec == 0) {
        res[i] = 1;
        D[dec] = a[i];
        dec++;
      } else {
        b = false;
        break;
      }
    }
  }
  if (b) {
    cout << "YES\n";
    for (i = 0; i < n; i++) {
      cout << res[i] << " ";
    }
    cout << "\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
