#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
long long t = 1, n, a[200010];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long lastinc = -1e6, lastdec = 1e6;
  for (int i = 0; i < n; i++) {
    if (a[i] > lastinc && a[i] < lastdec)
      if (a[i] < a[i + 1] && i != n - 1)
        lastinc = a[i], a[i] = 0;
      else
        lastdec = a[i], a[i] = 1;
    else if (a[i] > lastinc)
      lastinc = a[i], a[i] = 0;
    else if (a[i] < lastdec)
      lastdec = a[i], a[i] = 1;
    else {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; i++) cout << a[i] << ' ';
  cout << '\n';
  return 0;
}
