#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 2e5 + 1000;
int Min = inf, Max = -inf;
int a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] < Min && a[i] > Max) {
      if (a[i] > a[i + 1]) {
        Min = a[i];
        a[i] = 1;
      } else {
        Max = a[i];
        a[i] = 0;
      }
    } else if (a[i] < Min) {
      Min = a[i];
      a[i] = 1;
    } else if (a[i] > Max) {
      Max = a[i];
      a[i] = 0;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
