#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000 * 100 + 9;
int arr[MAX];
int ans[MAX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, v, ac, bc;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  ac = -1;
  bc = MAX;
  for (int i = 0; i < n; i++) {
    if (arr[i] > ac && arr[i] < bc) {
      if (arr[i] < arr[i + 1]) {
        ans[i] = 0;
        ac = arr[i];
      } else {
        ans[i] = 1;
        bc = arr[i];
      }
    } else if (arr[i] > ac) {
      ans[i] = 0;
      ac = arr[i];
    } else if (arr[i] < bc) {
      ans[i] = 1;
      bc = arr[i];
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
