#include <bits/stdc++.h>
using namespace std;
int a[200010], ans[200010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int L = -1, R = 200010;
  for (int i = 1; i <= n; i++) {
    int x = a[i], y = a[i + 1];
    if (a[i] <= L) {
      if (R > a[i]) {
        R = a[i];
        ans[i] = 1;
      } else {
        puts("NO");
        return 0;
      }
    } else if (a[i] >= R) {
      if (L < a[i]) {
        L = a[i];
        ans[i] = 0;
      } else {
        puts("NO");
        return 0;
      }
    } else {
      if (y >= R) {
        L = x;
        ans[i] = 0;
      } else if (y <= L) {
        R = x;
        ans[i] = 1;
      } else {
        if (x < y) {
          L = x;
          ans[i] = 0;
        } else {
          R = x;
          ans[i] = 1;
        }
      }
    }
  }
  puts("YES");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
