#include <bits/stdc++.h>
const int inf = 2e9;
using namespace std;
long long MOD = 1000000007;
typedef struct {
  int a, b, c;
} iii;
void mosA(vector<int> a) {
  for (int i = 0; i < a.size(); i++) printf("%d ", a[i]);
  printf("\n");
}
void mosP(vector<pair<int, int> > a) {
  for (int i = 0; i < a.size(); i++) printf("%d %d\n", a[i].first, a[i].second);
  printf("\n");
}
long long min_especial(long long a, long long b) {
  if (a != -1 && b != -1)
    return min(a, b);
  else
    return max(a, b);
}
bool ord(int a, int b) { return b < a; }
long long ans = 0;
int k, q, n, m, t, a, b;
vector<int> in, de, r;
int A[200005];
bool PI(int x) { return (!in.size()) || (x > in[in.size() - 1]); }
bool PD(int x) { return (!de.size()) || (x < de[de.size() - 1]); }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", A + i);
  for (int i = 0; i < (n); i++) {
    int x = A[i];
    if (PI(x) && PD(x) && i != n - 1) {
      if (A[i + 1] > x) {
        in.push_back(x);
        r.push_back(0);
      } else {
        de.push_back(x);
        r.push_back(1);
      }
      continue;
    }
    if (!PI(x) && !PD(x)) return !printf("NO\n");
    if (PI(x)) {
      in.push_back(x);
      r.push_back(0);
      continue;
    }
    if (PD(x)) {
      r.push_back(1);
      de.push_back(x);
      continue;
    }
  }
  printf("YES\n");
  mosA(r);
}
