#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
string res;
int incr = -1, decr = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    if (a[i] > incr and a[i] < decr) {
      if (a[i + 1] > a[i])
        incr = a[i], res.push_back('0');
      else
        decr = a[i], res.push_back('1');
    } else if (a[i] > incr)
      incr = a[i], res.push_back('0');
    else if (a[i] < decr)
      decr = a[i], res.push_back('1');
    else {
      cout << "NO\n";
      return 0;
    }
    res.push_back(' ');
  }
  cout << "YES\n" << res;
  return 0;
}
