#include <bits/stdc++.h>
using namespace std;
const int mod = 123456789;
const int N = 1e6 + 10;
void read(int &a) {
  a = 0;
  int d = 1;
  char ch;
  while (ch = getchar(), ch > '9' || ch < '0')
    if (ch == '-') d = -1;
  a = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') a = a * 10 + ch - '0';
  a *= d;
}
void write(int x) {
  if (x < 0) putchar(45), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int f[N], a[N];
int main() {
  int n;
  read(n);
  for (register int i = 0; i < n; i++) read(a[i]);
  int maxn = -1, minx = 0x3fffffff;
  for (register int i = 0; i < n; i++) {
    if (maxn < a[i] && (a[i] < a[i + 1] || a[i] >= minx))
      maxn = a[i], a[i] = 0;
    else if (a[i] < minx)
      minx = a[i], a[i] = 1;
    else
      return puts("NO"), 0;
  }
  puts("YES");
  for (register int i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
