#include <bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
int c[200005];
int vis[200005];
int re[200005];
int len1, len2;
int main() {
  int n;
  scanf("%d", &n);
  int flag = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (++vis[a[i]] > 2) flag = 1;
  }
  if (flag)
    printf("NO\n");
  else {
    flag = 0;
    b[len1++] = -1;
    c[len2++] = 0x3f3f3f3f;
    for (int i = 0; i < n; i++) {
      if (a[i] >= c[len2 - 1] && a[i] <= b[len1 - 1]) {
        flag = 1;
        break;
      }
      if (a[i] == c[len2 - 1])
        b[len1++] = a[i];
      else if (a[i] == b[len1 - 1]) {
        c[len2++] = a[i];
        re[i] = 1;
      } else if (a[i] >= a[i + 1]) {
        if (a[i] < c[len2 - 1]) {
          c[len2++] = a[i];
          re[i] = 1;
        } else
          b[len1++] = a[i];
      } else if (a[i] < a[i + 1]) {
        if (a[i] > b[len1 - 1])
          b[len1++] = a[i];
        else {
          c[len2++] = a[i];
          re[i] = 1;
        }
      }
    }
    if (flag)
      printf("NO\n");
    else {
      printf("YES\n");
      for (int i = 0; i < n; i++) printf("%d ", re[i]);
      printf("\n");
    }
  }
  return 0;
}
