#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 5;
int a[N], up[N], down[N], vis[N];
int main() {
  int n, j, k, flag;
  memset(vis, 0, sizeof(vis));
  up[0] = -INF, down[0] = INF;
  j = k = 0;
  flag = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (a[i] >= down[j] && a[i] <= up[k]) {
      flag = 0;
      break;
    } else if (a[i] < down[j] && a[i] > up[k]) {
      if (a[i] > a[i + 1]) {
        down[++j] = a[i];
        vis[i] = 1;
      } else {
        up[++k] = a[i];
      }
    } else if (a[i] < down[j]) {
      down[++j] = a[i];
      vis[i] = 1;
    } else {
      up[++k] = a[i];
    }
  }
  if (!flag)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 1; i <= n; i++) printf("%d ", vis[i]);
  }
  return 0;
}
