#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
void fail() {
  cout << "NO" << endl;
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << setprecision(12);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < int(n); i++) cin >> a[i];
  vector<bool> res(n);
  vector<int> incr, decr;
  for (int i = 0; i < int(n); i++) {
    int x = a[i];
    bool incr_ok = incr.empty() || x > incr.back();
    bool decr_ok = decr.empty() || x < decr.back();
    if (incr_ok && decr_ok) {
      if (i + 1 < n && x < a[i + 1]) {
        incr.push_back(x);
      } else {
        decr.push_back(x);
        res[i] = 1;
      }
    } else if (incr_ok) {
      incr.push_back(x);
    } else if (decr_ok) {
      decr.push_back(x);
      res[i] = 1;
    } else {
      fail();
    }
  }
  cout << "YES" << endl;
  for (int r : res) cout << r << " ";
  cout << endl;
}
