#include <bits/stdc++.h>
int n, x, a[200005];
int main() {
  scanf("%d", &n);
  int maxn = -1, minn = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  int i;
  for (i = 1; i <= n; i++) {
    if (a[i] <= maxn && a[i] >= minn)
      break;
    else if (a[i] > maxn && a[i] >= minn)
      maxn = a[i], a[i] = 0;
    else if (a[i] <= maxn && a[i] < minn)
      minn = a[i], a[i] = 1;
    else {
      if (a[i + 1] > a[i])
        maxn = a[i], a[i] = 0;
      else
        minn = a[i], a[i] = 1;
    }
  }
  if (i <= n)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int j = 1; j <= n; j++) printf("%d ", a[j]);
  }
}
