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