#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
int a[maxn];
bool ans[maxn];
priority_queue<int, vector<int>, greater<int> > dw;
priority_queue<int> up;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << "YES" << endl << 1 << endl;
    return 0;
  }
  up.push(-inf);
  dw.push(inf);
  int i = 1;
  if (a[i + 1] > a[i]) {
    up.push(a[i]);
    ans[i] = 0;
  } else if (a[i + 1] < a[i]) {
    dw.push(a[i]);
    ans[i] = 1;
  } else {
    up.push(a[i]);
    dw.push(a[++i]);
    ans[i - 1] = 0;
    ans[i] = 1;
  }
  i++;
  while (i <= n) {
    if (a[i] > up.top() && a[i] < dw.top()) {
      if (a[i + 1] > a[i]) {
        up.push(a[i]);
        ans[i] = 0;
      } else if (a[i + 1] < a[i]) {
        dw.push(a[i]);
        ans[i] = 1;
      } else {
        up.push(a[i]);
        dw.push(a[++i]);
        ans[i - 1] = 0;
        ans[i] = 1;
      }
    } else if (a[i] > up.top()) {
      up.push(a[i]);
      ans[i] = 0;
    } else if (a[i] < dw.top()) {
      dw.push(a[i]);
      ans[i] = 1;
    } else {
      cout << "NO" << endl;
      return 0;
    }
    i++;
  }
  cout << "YES" << endl;
  for (int j = 1; j <= n; j++) cout << ans[j] << " ";
  return 0;
}
