#include <bits/stdc++.h>
using namespace std;
int a[200005], f[200005], vis[200005], n, flag = 0;
int inc[200005], de[200005], cnt1, cnt2;
int main() {
  int i, p0, p1;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (flag) continue;
    if (f[a[i]] == 2) {
      flag = 1;
      continue;
    }
    f[a[i]]++;
  }
  if (flag) {
    printf("NO");
    return 0;
  }
  inc[0] = -1;
  de[0] = 200005 << 1;
  cnt1 = cnt2 = 0;
  int now, nxt;
  for (i = 0; i < n; ++i) {
    now = a[i];
    if (now <= inc[cnt1] && now >= de[cnt2]) {
      flag = 1;
      break;
    }
    if (now > inc[cnt1] && now < de[cnt2]) {
      if (i == n - 1)
        vis[i] = 1;
      else {
        nxt = a[i + 1];
        if (now <= nxt) {
          inc[++cnt1] = now;
        } else {
          de[++cnt2] = now;
          vis[i] = 1;
        }
      }
    } else if (now > inc[cnt1]) {
      inc[++cnt1] = now;
    } else if (now < de[cnt2]) {
      de[++cnt2] = now;
      vis[i] = 1;
    }
  }
  if (flag) {
    printf("NO\n");
  } else {
    printf("YES\n");
    for (i = 0; i < n; ++i) {
      printf("%d ", vis[i]);
    }
  }
  return 0;
}
