#include <bits/stdc++.h>
using namespace std;
void dbg_out() { cerr << "\b\b]\n"; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << H << ", ";
  dbg_out(T...);
}
const int INF = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> A(n);
  for (int &i : A) cin >> i;
  int inc = -INF, dec = INF;
  vector<int> ans(n, 0);
  for (int i = 0; i < n; ++i) {
    if (A[i] > inc and A[i] < dec) {
      if (i + 1 < n) {
        if (A[i + 1] >= A[i]) {
          inc = A[i];
        } else {
          dec = A[i];
          ans[i] = 1;
        }
      }
    } else if (A[i] > inc) {
      inc = A[i];
    } else if (A[i] < dec) {
      dec = A[i];
      ans[i] = 1;
    } else {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i : ans) cout << i << ' ';
  return 0;
}
