#include <bits/stdc++.h>
using namespace std;
int n, a[200100], b[200100];
vector<int> vec1, vec2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    int kol = 0;
    if (vec1.empty() || vec1.back() < a[i]) ++kol;
    if (vec2.empty() || vec2.back() > a[i]) ++kol;
    if (kol == 0) return cout << "NO", 0;
    if (kol == 1) {
      if (vec1.empty() || vec1.back() < a[i]) {
        vec1.push_back(a[i]);
      } else {
        vec2.push_back(a[i]);
        b[i] = 1;
      }
    } else {
      if (i == n) {
        vec1.push_back(a[i]);
      } else {
        if (a[i] < a[i + 1]) {
          vec1.push_back(a[i]);
        } else {
          vec2.push_back(a[i]);
          b[i] = 1;
        }
      }
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) cout << b[i] << ' ';
}
