#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n, up, down;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  up = -1;
  down = 200005;
  for (int i = 1; i <= n; ++i) {
    if (a[i] < down && a[i] > up) {
      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 {
      printf("NO");
      return 0;
    }
  }
  printf("YES\n");
  for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
  return 0;
}
