#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a;
  vector<int> b;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; ++i) {
    int x = arr[i];
    int y = -1;
    if (i + 1 < n) y = arr[i + 1];
    if ((a.empty() or b.empty() or (arr[a.back()] < x and arr[b.back()] > x))) {
      if (y > x) {
        a.push_back(i);
      } else
        b.push_back(i);
    } else if (arr[a.back()] < x) {
      a.push_back(i);
    } else if (arr[b.back()] > x) {
      b.push_back(i);
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  vector<int> res(n, 0);
  for (int &e : b) res[e] = 1;
  cout << "YES" << endl;
  for (int i = 0; i < n; ++i) {
    cout << res[i] << ' ';
  }
  cout << endl;
  42;
  return 0;
}
