#include <bits/stdc++.h>
using namespace std;
vector<int> H;
vector<int> L;
int a[200001];
bool vis[200001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  bool T = 0;
  for (int i = 1; i <= n;) {
    bool faH = 0, faL = 0;
    int tailH = H.size() - 1, tailL = L.size() - 1;
    if (H.size() == 0)
      faH = 1;
    else if (H[tailH] < a[i])
      faH = 1;
    if (L.size() == 0)
      faL = 1;
    else if (L[tailL] > a[i])
      faL = 1;
    if (faH == 0 && faL == 0) {
      T = 1;
      break;
    }
    if (faH == 0 && faL == 1) {
      L.push_back(a[i]);
      vis[i] = 1;
      i++;
    }
    if (faH == 1 && faL == 0) {
      H.push_back(a[i]);
      vis[i] = 0;
      i++;
    }
    if (faH == 1 && faL == 1) {
      if (a[i] < a[i + 1]) {
        H.push_back(a[i]);
        vis[i] = 0;
        i++;
      } else if (a[i] > a[i + 1]) {
        L.push_back(a[i]);
        vis[i] = 1;
        i++;
      } else {
        H.push_back(a[i]);
        L.push_back(a[i + 1]);
        vis[i] = 0;
        vis[i + 1] = 1;
        i += 2;
      }
    }
  }
  if (T)
    puts("NO");
  else {
    puts("YES");
    for (int i = 1; i <= n; i++) {
      printf("%d ", vis[i]);
    }
  }
}
