#include <bits/stdc++.h>
using namespace std;
int a[1000005];
bool mark[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int i, j, k, l, m, n, t;
  cin >> n;
  vector<int> inc, dec;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      if (dec.size() == 0 || dec[dec.size() - 1] > a[i]) {
        mark[i] = 1;
        dec.push_back(a[i]);
      } else {
        inc.push_back(a[i]);
      }
    } else {
      if (inc.size() == 0 || inc[inc.size() - 1] < a[i]) {
        inc.push_back(a[i]);
      } else {
        mark[i] = 1;
        dec.push_back(a[i]);
      }
    }
  }
  if (inc.size() == 0 || inc[inc.size() - 1] < a[n - 1]) {
    inc.push_back(a[n - 1]);
  } else if (dec.size() == 0 || dec[dec.size() - 1] > a[n - 1]) {
    dec.push_back(a[n - 1]);
    mark[n - 1] = 1;
  } else {
    cout << "NO" << endl;
    return 0;
  }
  for (i = 1; i < inc.size(); i++) {
    if (inc[i] <= inc[i - 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (i = 1; i < dec.size(); i++) {
    if (dec[i] >= dec[i - 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (i = 0; i < n; i++) {
    cout << mark[i] << " ";
  }
  cout << endl;
}
