#include <bits/stdc++.h>
using namespace std;
string can2(vector<int> a, vector<int> is, vector<int> ds, int pos) {
  int x = is[pos];
  is.erase(is.begin() + pos);
  int p = lower_bound(ds.begin(), ds.end(), x) - ds.begin();
  ds.insert(ds.begin() + p, x);
  bool ok = true;
  int last = -1;
  for (auto i : is) {
    ok &= a[i] > last;
    last = a[i];
  }
  last = 1e9;
  for (auto i : ds) {
    ok &= a[i] < last;
    last = a[i];
  }
  if (!ok) return "";
  string ans = string(a.size(), '1');
  for (auto i : is) ans[i] = '0';
  return ans;
}
bool can(vector<int> a, vector<int> is, vector<int> ds, int pos) {
  int x = ds[pos];
  ds.erase(ds.begin() + pos);
  int p = lower_bound(is.begin(), is.end(), x) - is.begin();
  is.insert(is.begin() + p, x);
  string ans = "";
  if (p > 0) ans = can2(a, is, ds, p - 1);
  if (p + 1 < is.size() && ans == "") ans = can2(a, is, ds, p + 1);
  if (ans == "") return false;
  cout << "YES\n";
  for (auto &i : ans) cout << i << " \n"[&i == &ans.back()];
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  vector<int> lis, where, prv(n, -1);
  for (auto &x : a) {
    int i = &x - &a[0];
    auto it = lower_bound(lis.begin(), lis.end(), x) - lis.begin();
    if (it == lis.size()) {
      lis.push_back(x);
      prv[i] = where.size() ? where.back() : -1;
      where.push_back(i);
    } else {
      lis[it] = x;
      prv[i] = it ? where[it - 1] : -1;
      where[it] = i;
    }
  }
  lis.clear();
  string ans = string(n, '1');
  for (int i = where.back(); i != -1; i = prv[i])
    lis.push_back(i), ans[i] = '0';
  reverse(lis.begin(), lis.end());
  vector<int> ds;
  int nds = 0, pos;
  for (int i = 0, last = 1e9; i < n; ++i)
    if (ans[i] == '1') {
      if (last <= a[i]) ++nds, pos = ds.size();
      ds.push_back(i);
      last = a[i];
    }
  if (nds == 0) {
    cout << "YES\n";
    for (auto &i : ans) cout << i << " \n"[&i == &ans.back()];
    return 0;
  }
  if (nds == 1) {
    if (can(a, lis, ds, pos)) return 0;
    if (can(a, lis, ds, pos - 1)) return 0;
  }
  cout << "NO\n";
  return 0;
}
