#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long mod = 1e9 + 7;
const int mn = 2e5 + 10;
int a[mn], vis[mn];
int dp[mn][3];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[0][0] = -1, dp[0][1] = inf;
  for (int i = 1; i < n; i++) {
    if (a[i] > dp[i - 1][0] && a[i] < dp[i - 1][1]) {
      if (a[i + 1] > a[i]) {
        dp[i][0] = a[i];
        dp[i][1] = dp[i - 1][1];
        vis[i] = 0;
      } else if (a[i + 1] < a[i]) {
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = a[i];
        vis[i] = 1;
      } else if (a[i + 1] == a[i]) {
        dp[i][0] = a[i];
        dp[i][1] = dp[i - 1][1];
        dp[i + 1][1] = a[i + 1];
        dp[i + 1][0] = dp[i][0];
        vis[i] = 0, vis[i + 1] = 1;
        i++;
      }
    } else if (a[i] > dp[i - 1][0]) {
      dp[i][0] = a[i];
      dp[i][1] = dp[i - 1][1];
      vis[i] = 0;
    } else if (a[i] < dp[i - 1][1]) {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = a[i];
      vis[i] = 1;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (a[n] > dp[n - 1][0])
    vis[n] = 0;
  else if (a[n] < dp[n - 1][1])
    vis[n] = 1;
  else {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << vis[i] << ' ';
  cout << endl;
}
