#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const double eps = 1e-10;
const long long N = 2e5 + 7;
const long long MOD = 1e9 + 7;
long long pw(long long b, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * b;
    b = b * b;
    p >>= 1;
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n + 2);
  for (long long i = 1; i < n + 1; i++) cin >> a[i];
  a[0] = -0x3f3f3f3f3f3f3f3fLL;
  a[n + 1] = 0x3f3f3f3f3f3f3f3fLL;
  vector<long long> inc({0}), dec({n + 1});
  for (long long i = 1; i < n + 1; i++) {
    if (a[i] <= a[inc.back()] && a[i] >= a[dec.back()]) {
      cout << "NO";
      return 0;
    }
    if (a[i] > a[inc.back()] && a[i] >= a[dec.back()]) {
      inc.push_back(i);
    } else if (a[i] <= a[inc.back()] && a[i] < a[dec.back()]) {
      dec.push_back(i);
    } else if (i + 1 < n + 1 && a[i + 1] > a[i]) {
      inc.push_back(i);
    } else {
      dec.push_back(i);
    }
  }
  long long x = inc.size(), y = dec.size();
  long long i = 1, j = 1;
  cout << "YES" << '\n';
  while (i < x || j < y) {
    if (i == x)
      cout << 1 << ' ', j++;
    else if (j == y)
      cout << 0 << ' ', i++;
    else if (inc[i] < dec[j])
      cout << 0 << ' ', i++;
    else
      cout << 1 << ' ', j++;
  }
  return 0;
}
