#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int in = -1, de = 1000000;
  for (int i = 0; i < n; i++) {
    if (a[i] >= de && a[i] <= in) {
      cout << "NO";
      return 0;
    } else if (a[i] > in && a[i] < de) {
      if (i == n - 1) {
        a[i] = 0;
        break;
      }
      int y = a[i + 1];
      if (y > a[i]) {
        in = a[i];
        a[i] = 0;
      } else {
        de = a[i];
        a[i] = 1;
      }
    } else if (a[i] > in) {
      in = a[i];
      a[i] = 0;
    } else {
      de = a[i];
      a[i] = 1;
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
