#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<long long, vector<long long>, greater<long long>>
    minHeap;
const int N = 2e5 + 33;
long long n;
int arr[N], ans[N];
int dp[N][2];
int main() {
  ios::sync_with_stdio(false);
  dp[0][0] = 1e9;
  dp[0][1] = -1e9;
  for (int i = 1; i < N; i++) {
    dp[i][0] = -1e9;
    dp[i][1] = 1e9;
  }
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 1; i < n; i++) {
    if (arr[i] > arr[i - 1]) {
      dp[i][0] = dp[i - 1][0];
    }
    if (arr[i] < arr[i - 1]) {
      dp[i][1] = dp[i - 1][1];
    }
    if (arr[i] > dp[i - 1][1]) {
      dp[i][0] = max(arr[i - 1], dp[i][0]);
    }
    if (arr[i] < dp[i - 1][0]) {
      dp[i][1] = min(arr[i - 1], dp[i][1]);
    }
  }
  if (dp[n - 1][0] == -1e9 && dp[n - 1][1] == 1e9) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  bool bad = 0;
  int l = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (l == 0) {
      if (dp[i + 1][0] == dp[i][0]) {
        ans[i] = 0;
      } else if (dp[i + 1][0] == arr[i]) {
        ans[i] = 1;
        l = 1;
      } else {
        bad = 1;
        break;
      }
    } else {
      if (dp[i + 1][1] == dp[i][1]) {
        ans[i] = 1;
      } else if (dp[i + 1][1] == arr[i]) {
        ans[i] = 0;
        l = 0;
      } else {
        bad = 1;
        break;
      }
    }
  }
  if (bad) {
    l = 1;
    ans[n - 1] = 1;
    for (int i = n - 2; i >= 0; i--) {
      if (l == 0) {
        if (dp[i + 1][0] == dp[i][0]) {
          ans[i] = 0;
        } else if (dp[i + 1][0] == arr[i]) {
          ans[i] = 1;
          l = 1;
        } else {
          bad = 1;
          break;
        }
      } else {
        if (dp[i + 1][1] == dp[i][1]) {
          ans[i] = 1;
        } else if (dp[i + 1][1] == arr[i]) {
          ans[i] = 0;
          l = 0;
        } else {
          bad = 1;
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
