#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, a[200005], ans[200005];
int in[200005], de[200005];
int toi[200005], tod[200005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  in[0] = INF;
  de[0] = -INF;
  a[0] = -1;
  for (int i = 1; i <= n; i++) {
    in[i] = -INF;
    de[i] = INF;
    if (a[i] > a[i - 1]) {
      if (in[i - 1] > in[i]) {
        in[i] = in[i - 1];
        toi[i] = 0;
      }
    }
    if (a[i] > de[i - 1]) {
      if (a[i - 1] > in[i]) {
        in[i] = a[i - 1];
        toi[i] = 1;
      }
    }
    if (a[i] < a[i - 1]) {
      if (de[i - 1] < de[i]) {
        de[i] = de[i - 1];
        tod[i] = 1;
      }
    }
    if (a[i] < in[i - 1]) {
      if (a[i - 1] < de[i]) {
        de[i] = a[i - 1];
        tod[i] = 0;
      }
    }
  }
  if (in[n] == -INF && de[n] == INF) return 0 * printf("NO\n");
  int cur = 0;
  if (in[n] == -INF) cur = 1;
  for (int i = n; i >= 1; i--) {
    ans[i] = cur;
    if (cur == 0)
      cur = toi[i];
    else
      cur = tod[i];
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++) {
    if (i == 1)
      printf("%d", ans[i]);
    else
      printf(" %d", ans[i]);
  }
  printf("\n");
}
