#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n;
int A[200003];
int dp[200003][2];
int ans[200003];
pair<int, int> par[200003][2];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  for (int i = 0; i < n; i++) {
    dp[i][0] = INF;
    dp[i][1] = -1;
  }
  dp[0][0] = -1;
  dp[0][1] = INF;
  par[0][0] = {-1, -1};
  par[0][1] = {-1, -1};
  for (int i = 1; i < n; i++) {
    if (A[i] < A[i - 1] && dp[i][0] > dp[i - 1][0]) {
      dp[i][0] = dp[i - 1][0];
      par[i][0] = {i - 1, 0};
    }
    if (dp[i - 1][1] > A[i] && dp[i][0] > A[i - 1]) {
      dp[i][0] = A[i - 1];
      par[i][0] = {i - 1, 1};
    }
    if (A[i] > A[i - 1] && dp[i][1] < dp[i - 1][1]) {
      dp[i][1] = dp[i - 1][1];
      par[i][1] = {i - 1, 1};
    }
    if (dp[i - 1][0] < A[i] && dp[i][1] < A[i - 1]) {
      dp[i][1] = A[i - 1];
      par[i][1] = {i - 1, 0};
    }
  }
  int x = -1, y = -1;
  if (dp[n - 1][0] != INF) x = n - 1, y = 0;
  if (dp[n - 1][1] != -1) x = n - 1, y = 1;
  if (x == -1 || y == -1)
    printf("NO\n");
  else {
    printf("YES\n");
    while (x != -1) {
      ans[x] = 1 ^ y;
      pair<int, int> nxt = par[x][y];
      x = nxt.first;
      y = nxt.second;
    }
    for (int i = 0; i < n; i++)
      printf("%d%c", ans[i], (i == n - 1) ? '\n' : ' ');
  }
}
