#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 2e5 + 5, inf = 1e9;
int dp[N][2], a[N];
bool bad[N][2];
int P[N][2];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  vector<int> ans(n + 1);
  dp[0][0] = inf;
  dp[0][1] = -1;
  for (int i = 1, val; i <= n; i++) {
    cin >> val;
    a[i] = val;
    dp[i][0] = INT_MIN;
    dp[i][1] = INT_MAX;
    bad[i][0] = bad[i][1] = 1;
    if ((!bad[i - 1][0]) && (i == 1 || a[i - 1] < val))
      dp[i][0] = dp[i - 1][0], bad[i][0] = 0, P[i][0] = 0;
    if ((!bad[i - 1][1]) && dp[i - 1][1] < a[i] &&
        (bad[i][0] || dp[i][0] < a[i - 1])) {
      dp[i][0] = a[i - 1];
      bad[i][0] = 0;
      P[i][0] = 1;
    }
    if ((!bad[i - 1][1]) && (i == 1 || a[i - 1] > val))
      dp[i][1] = dp[i - 1][1], bad[i][1] = 0, P[i][1] = 1;
    if ((!bad[i - 1][0]) && dp[i - 1][0] > a[i] &&
        (bad[i][1] || dp[i][1] > a[i - 1])) {
      dp[i][1] = a[i - 1];
      bad[i][1] = 0;
      P[i][1] = 0;
    }
    if (bad[i][0] && bad[i][1]) {
      cout << "NO";
      return 0;
    }
  }
  int tp = -1;
  for (int i = n; i > 0;) {
    if (tp == -1) {
      if (bad[i][0] == 0)
        tp = 0;
      else
        tp = 1;
    }
    ans[i] = tp;
    tp = P[i][tp];
    i--;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
}
