#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> data(n);
  for (auto &v : data) cin >> v;
  vector<int> ans[2], res;
  for (int i = 0; i < n; i++) {
    int could = 0;
    if (!ans[0].size() || ans[0].back() < data[i]) could += 1;
    if (!ans[1].size() || ans[1].back() > data[i]) could += 2;
    if (could == 0) {
      cout << "NO\n";
      return 0;
    } else if (could == 1) {
      ans[0].push_back(data[i]);
      res.push_back(0);
    } else if (could == 2) {
      ans[1].push_back(data[i]);
      res.push_back(1);
    } else {
      if (i + 1 < n && data[i] < data[i + 1]) {
        ans[0].push_back(data[i]);
        res.push_back(0);
      } else {
        ans[1].push_back(data[i]);
        res.push_back(1);
      }
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) cout << res[i] << " \n"[i == n - 1];
}
