#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
int ans[maxn];
vector<int> up, down;
int main() {
  int n;
  while (cin >> n) {
    int F = 0;
    memset(a, 0, sizeof(a));
    memset(ans, 0, sizeof(ans));
    up.clear(), down.clear();
    for (int i = 0; i < n; i++) cin >> a[i];
    int cntup = 0, cntdown = 0;
    up.push_back(-1), down.push_back(9999999);
    int i;
    for (i = 0; i < n; i++) {
      if (i == 0) {
        if (a[0] > a[1])
          down.push_back(0), cntdown++;
        else if (a[0] < a[1])
          up.push_back(0), cntup++;
        else {
          down.push_back(0), up.push_back(1), i = 1, cntup = 1, cntdown = 1;
        }
        continue;
      }
      int f1 = 0, f2 = 0;
      int t;
      t = cntup == 0 ? -1 : a[up[cntup]];
      if (a[i] > t) f1 = 1;
      t = cntdown == 0 ? 999999 : a[down[cntdown]];
      if (a[i] < t) f2 = 1;
      if (f1 == 0 && f2 == 0) {
        F = 1;
        break;
      } else if (f1 == 0 && f2 == 1) {
        down.push_back(i), cntdown++;
      } else if (f1 == 1 && f2 == 0) {
        up.push_back(i), cntup++;
      } else {
        if (i != n - 1) {
          if (a[i] == a[i + 1]) {
            down.push_back(i), up.push_back(i + 1), i++, cntup++, cntdown++;
          } else if (a[i] > a[i + 1]) {
            down.push_back(i), cntdown++;
          } else {
            up.push_back(i), cntup++;
          }
        } else {
          down.push_back(i), cntdown++;
        }
      }
    }
    if (F == 1) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
      if (cntdown > 1)
        for (int j = 1; j < down.size(); j++) ans[down[j]] = 1;
      for (int j = 0; j < n; j++) cout << ans[j] << " ";
    }
  }
}
