#include <bits/stdc++.h>
const int N = 2e5 + 5;
template <class T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
int f[2][N], g[2][N], n, a[N], vis[2][N], tag, pos, Ans[N];
inline void solve() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  a[n + 1] = (2000001);
  a[n + 2] = -1;
  tag = 1;
  for (int i = 2; i <= n; i++)
    if (a[i] > a[i - 1]) tag = 0;
  if (tag) {
    puts("YES");
    printf("0");
    for (int i = 2; i <= n; i++) printf(" 1");
    return;
  }
  tag = 1;
  for (int i = 2; i <= n; i++)
    if (a[i] < a[i - 1]) tag = 0;
  if (tag) {
    puts("YES");
    printf("1");
    for (int i = 2; i <= n; i++) printf(" 0");
    return;
  }
  f[0][1] = (n + 1);
  f[1][1] = (n + 2);
  vis[0][1] = 1;
  vis[1][1] = 1;
  for (int i = 1; i <= n - 1; i++) {
    if (!vis[0][i] && !vis[1][i]) continue;
    if (vis[0][i]) {
      if (a[i + 1] > a[i])
        f[0][i + 1] = f[0][i], g[0][i + 1] = i, vis[0][i + 1] = 1;
      if (a[i + 1] < a[f[0][i]])
        f[1][i + 1] = i, g[1][i + 1] = f[0][i], vis[1][i + 1] = 1;
    }
    if (vis[1][i]) {
      if (a[i + 1] < a[i]) {
        if (vis[1][i + 1] && a[f[1][i + 1]] < a[f[1][i]]) continue;
        f[1][i + 1] = f[1][i];
        g[1][i + 1] = i;
        vis[1][i + 1] = 1;
      }
      if (a[i + 1] > a[f[1][i]]) {
        if (vis[0][i + 1] && a[f[0][i]] > a[i]) continue;
        f[0][i + 1] = i;
        g[0][i + 1] = f[1][i];
        vis[0][i + 1] = 1;
      }
    }
  }
  if (!vis[0][n] && !vis[1][n]) return (void)(puts("NO"));
  puts("YES");
  if (vis[1][n])
    tag = 1;
  else
    tag = 0;
  pos = n;
  for (; pos <= n && pos; pos = g[tag][pos]) Ans[pos] = 1;
  for (int i = 1; i <= n; i++)
    if (Ans[i])
      printf("%d ", tag);
    else
      printf("%d ", tag ^ 1);
}
int main() { solve(); }
