#include <bits/stdc++.h>
using namespace std;
int bit[2][200007];
void update(int f, int first, int second = 1) {
  first++;
  if (f == 1)
    for (; first <= 200005; first += first & (-first)) bit[f][first] += second;
  else
    for (; first <= 200005; first += first & (-first))
      bit[f][first] = max(bit[f][first], second);
}
int query(int f, int first) {
  first++;
  int res = 0;
  if (f == 1)
    for (; first > 0; first -= first & (-first)) res += bit[f][first];
  else
    for (; first > 0; first -= first & (-first)) res = max(res, bit[f][first]);
  return res;
}
int n, a[200005], res[200005], ans[200005];
int check(vector<int> v) {
  for (int i = 1; i < (int)v.size(); i++)
    if (v[i] <= v[i - 1]) return 0;
  return 1;
}
void go(int w) {
  memset(res, 0, sizeof res);
  memset(ans, 0, sizeof ans);
  memset(bit, 0, sizeof bit);
  vector<int> v1, v2;
  for (int i = n - 1; i >= 0; i--) {
    ans[i] = query(0, a[i] - 1) + 1;
    update(0, a[i], ans[i]);
    update(1, a[i], 1);
  }
  for (int i = 0; i < n; i++) {
    update(1, a[i], -1);
    if (ans[i] - 1 == query(1, a[i] - 1) and
        ((int)v1.size() == 0 or a[i] > v1.back()))
      res[i] = w, v1.push_back(a[i]);
    else
      res[i] = 1 - w, v2.push_back(a[i]);
  }
  reverse((v2).begin(), (v2).end());
  if (check(v1) and check(v2)) {
    cout << "YES" << '\n';
    for (int i = 0; i < n; i++) cout << res[i] << " ";
    cout << '\n';
    exit(0);
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  go(0);
  for (int i = 0; i < n; i++) a[i] = 200003 - a[i];
  go(1);
  cout << "NO" << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
