#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int a[N];
int inc[N], dec1[N], cnt1, cnt2;
int ans[N];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int i;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dec1[0] = inf;
  inc[0] = -1;
  for (i = 1; i <= n; i++) {
    if (a[i] <= inc[cnt1] && a[i] >= dec1[cnt2]) {
      cout << "NO" << endl;
      return 0;
    } else if (a[i] > inc[cnt1] && a[i] < dec1[cnt2]) {
      if (a[i] > a[i + 1]) {
        dec1[++cnt2] = a[i];
        ans[i] = 1;
      } else {
        inc[++cnt1] = a[i];
        ans[i] = 0;
      }
    } else if (a[i] > inc[cnt1]) {
      inc[++cnt1] = a[i];
      ans[i] = 0;
    } else {
      dec1[++cnt2] = a[i];
      ans[i] = 1;
    }
  }
  cout << "YES" << endl;
  for (i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
