#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
int n;
int a[200002], ud[200001];
int u = -1, d = 2147483647;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  a[n + 1] = 2147483647;
  for (int i = 1; i <= n; i++) {
    bool x = a[i] > u, y = a[i] < d;
    if (x && !y) {
      ud[i] = 0;
      u = a[i];
    }
    if (!x && y) {
      ud[i] = 1;
      d = a[i];
    }
    if (!x && !y) {
      printf("NO\n");
      return 0;
    }
    if (x && y) {
      if (a[i + 1] > a[i]) {
        ud[i] = 0;
        u = a[i];
      } else {
        ud[i] = 1;
        d = a[i];
      }
    }
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", ud[i]);
  return 0;
}
