#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
int n, a[maxn];
bool ans[maxn];
priority_queue<int, vector<int>, greater<int> > inde;
priority_queue<int> de;
int main() {
  std::ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  if (n == 1) {
    cout << "YES" << endl << 1 << endl;
    return 0;
  }
  de.push(-inf), inde.push(inf);
  int i = 1;
  if (a[i + 1] > a[i])
    de.push(a[i]), ans[i] = 0;
  else if (a[i + 1] < a[i])
    inde.push(a[i]), ans[i] = 1;
  else
    de.push(a[i]), inde.push(a[++i]), ans[i - 1] = 0, ans[i] = 1;
  ++i;
  while (i <= n) {
    if (a[i] > de.top() && a[i] < inde.top()) {
      if (a[i + 1] > a[i])
        de.push(a[i]), ans[i] = 0;
      else if (a[i + 1] < a[i])
        inde.push(a[i]), ans[i] = 1;
      else
        de.push(a[i]), inde.push(a[++i]), ans[i - 1] = 0, ans[i] = 1;
    } else if (a[i] > de.top())
      de.push(a[i]), ans[i] = 0;
    else if (a[i] < inde.top())
      inde.push(a[i]), ans[i] = 1;
    else {
      cout << "NO" << endl;
      return 0;
    }
    ++i;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
  return 0;
}
