#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 11;
int a[maxn];
int flag = 0;
int main() {
  int up = -1, down = maxn;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a[n] = maxn;
  for (int i = 0; i < n; i++) {
    if (a[i] > up && a[i] < down)
      if (a[i] < a[i + 1])
        up = a[i], a[i] = 0;
      else
        down = a[i], a[i] = 1;
    else if (a[i] < down) {
      down = a[i], a[i] = 1;
    } else if (a[i] > up) {
      up = a[i], a[i] = 0;
    } else {
      flag = 1;
      break;
    }
  }
  if (flag) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
