#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 1e9;
int dp[maxn][2];
int p[maxn][2];
int n, a[maxn];
int pre[maxn][2];
bool vis[maxn];
int main() {
  scanf("%d", &n);
  dp[0][0] = -inf;
  dp[0][1] = inf;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[i][0] = p[i][1] = i;
    dp[i][0] = inf, dp[i][1] = -inf;
    if (i > 1 && a[i] > a[i - 1]) p[i][1] = p[i - 1][1];
    if (i > 1 && a[i] < a[i - 1]) p[i][0] = p[i - 1][0];
  }
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      dp[i][0] = -inf;
      dp[i][1] = inf;
      continue;
    }
    int q = p[i - 1][1];
    if ((q == 1 || a[q - 1] > a[i]) && dp[q - 1][0] < a[q]) {
      if (q == i) {
        if (dp[i][0] > dp[q - 1][0]) dp[i][0] = dp[q - 1][0], pre[i][0] = q - 1;
      } else {
        if (dp[i][0] > a[i - 1]) dp[i][0] = a[i - 1], pre[i][0] = q - 1;
      }
    }
    int t = upper_bound(a + q, a + i, a[i]) - a;
    if (a[t] > a[i]) {
      if (t != i - 1 && dp[t][0] < a[t + 1]) {
        if (dp[i][0] > a[i - 1]) dp[i][0] = a[i - 1], pre[i][0] = t;
      }
      if (dp[i][0] > dp[i - 1][0]) dp[i][0] = dp[i - 1][0], pre[i][0] = i - 1;
    }
    q = p[i - 1][0];
    if ((q == 1 || a[q - 1] < a[i]) && dp[q - 1][1] > a[q]) {
      if (q == i) {
        if (dp[i][1] < dp[q - 1][1]) dp[i][1] = dp[q - 1][1], pre[i][1] = q - 1;
      } else {
        if (dp[i][1] < a[i - 1]) dp[i][1] = a[i - 1], pre[i][1] = q - 1;
      }
    }
    t = upper_bound(a + q, a + i, a[i], greater<int>()) - a;
    if (a[t] < a[i]) {
      if (t != i - 1 && dp[t][1] > a[t + 1]) {
        if (dp[i][1] < a[i - 1]) dp[i][1] = a[i - 1], pre[i][1] = t;
      }
      if (dp[i][1] < dp[i - 1][1]) dp[i][1] = dp[i - 1][1], pre[i][1] = i - 1;
    }
  }
  if (dp[n][1] == -inf && dp[n][0] == inf)
    printf("NO\n");
  else {
    printf("YES\n");
    int t = n;
    int st = 1;
    if (dp[n][0] != inf) st = 0;
    while (t != 0) {
      vis[t] = 1;
      t = pre[t][st];
    }
    for (int i = 1; i <= n; i++) printf("%d ", vis[i] ^ st);
    printf("\n");
  }
  return 0;
}
