#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          if(i < (sz(aux2) - 1)){
            if(aux[j].F <= aux2[i+1].F) continue;
          }
            // if(j < sz(aux) - 1)
            //   if(aux[j+1].F <= aux2[i].F) continue;
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          // if(a[1] == 189999){
          //   cout << "I : " << i << endl;
          //   cout << aux2[i].S << " - " << aux[j].S << endl;
          //   cout << aux2[180503].F << " -- " << aux2[180504].F << endl;
          // }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }
  if(aux[1] == 189999) cout << 1 << endl;
  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          // if(i < sz(aux2) - 1){
            // if(aux[j].F < aux2[i+1].F) continue;
            // if(j < sz(aux) - 1)
              // if(aux[j+1].F < aux2[i].F) continue;
          // }
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          if(a[1] == 189999){
            cout << aux2[i].S << " - " << aux[j].S << endl;
            cout << aux2[180503].F << " -- " << aux2[180504].F << endl;
          }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          if(i < sz(aux2) - 1){
            if(aux[j].F < aux2[i+1].F) continue;
            // if(j < sz(aux) - 1)
              // if(aux[j+1].F < aux2[i].F) continue;
          }
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          // cout << aux2[i].S << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  // for(auto i : anss) cout << i << " ";
  // cout << endl;

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // int c = 0;
  // int aaa = 0;
  // for(int i=200000;i>=0;i--){
  //   if(c == 29) cout << aaa++ << " ", c = 0;
  //   else cout << i << " ";
  //   c++;
  // }

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          at[aux[j].S] = 1;
          at[aux2[i-1].S] = 0;

          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;

          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  // for(auto i : anss) cout << i << " ";
  // cout << endl;

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // int c = 0;
  // int aaa = 0;
  // for(int i=200000;i>=0;i--){
  //   if(c == 29) cout << aaa++ << " ", c = 0;
  //   else cout << i << " ";
  //   c++;
  // }

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i].F){
          at[aux2[j].S] = 0;
          // at[aux2[i-1].S] = 0;

          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;

          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  // for(auto i : anss) cout << i << " ";
  // cout << endl;

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // int c = 0;
  // int aaa = 0;
  // for(int i=200000;i>=0;i--){
  //   if(c == 29) cout << aaa++ << " ", c = 0;
  //   else cout << i << " ";
  //   c++;
  // }

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }

  int pos = -1;

  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      pos = i;
      break;
    }
  }

  if(pos != -1){
    bool att = false;
    for(int i=0;i<sz(aux);i++){
      if(pos){
        if(aux[i].F < aux2[pos-1].F){
          at[aux2[pos].S] = 1;
          at[aux[i].S] = 0;
          att = true;
          break;
        }
      }
    }

    if(att){
      cout << "YES" << endl;
      for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
      cout << endl;
      exit(0);
    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  // if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          if(i < sz(aux2) - 1){
            if(aux[j].F <= aux2[i+1].F) continue;
            // if(j < sz(aux) - 1)
              // if(aux[j+1].F <= aux2[i].F) continue;
          }
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          // if(a[1] == 189999){
          //   cout << "I : " << i << endl;
          //   cout << aux2[i].S << " - " << aux[j].S << endl;
          //   cout << aux2[180503].F << " -- " << aux2[180504].F << endl;
          // }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          // if(i < sz(aux2) - 1){
            // if(aux[j].F < aux2[i+1].F) continue;
            // if(j < sz(aux) - 1)
              // if(aux[j+1].F < aux2[i].F) continue;
          // }
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          // if(a[0] == 189999) cout << aux2[j].S << " - " << aux2[i].S << endl;
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[0] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }

  int pos = -1;

  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      pos = i;
      break;
    }
  }

  if(pos != -1){
    bool att = false;
    for(int i=0;i<sz(aux);i++){
      if(pos){
        if(aux[i].F < aux2[pos-1].F){
          at[aux2[pos].S] = 0;
          at[aux[i].S] = 1;
          att = true;
          break;
        }
      }
    }

    if(att){
      cout << "YES" << endl;
      for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
      cout << endl;
      exit(0);
    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  // if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          if(i < (sz(aux2) - 1)){
            if(aux[j].F <= aux2[i+1].F) continue;
          }
            // if(j < sz(aux) - 1)
            //   if(aux[j+1].F <= aux2[i].F) continue;
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          // if(a[1] == 189999){
          //   cout << "I : " << i << endl;
          //   cout << aux2[i].S << " - " << aux[j].S << endl;
          //   cout << aux2[180503].F << " -- " << aux2[180504].F << endl;
          // }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          // if(i < (sz(aux2) - 1)){
            // if(aux[j].F <= aux2[i+1].F) continue;
          // }
            // if(j < sz(aux) - 1)
            //   if(aux[j+1].F <= aux2[i].F) continue;
          at[aux[j].S] = 0;
          at[aux2[i].S] = 1;

          // if(a[1] == 189999){
          //   cout << "I : " << i << endl;
          //   cout << aux2[i].S << " - " << aux[j].S << endl;
          //   cout << aux2[180503].F << " -- " << aux2[180504].F << endl;
          // }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }
  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          at[aux[j].S] = 0;
          at[aux2[i-1].S] = 1;

          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << at[i] << " ";
          cout << endl;

          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  // for(auto i : anss) cout << i << " ";
  // cout << endl;

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << !at[i] << " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          // if(i < sz(aux2) - 1){
            // if(aux[j].F < aux2[i+1].F) continue;
            // if(j < sz(aux) - 1)
              // if(aux[j+1].F < aux2[i].F) continue;
          // }
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          if(a[1] == 189999){
            cout << "I : " << i << endl;
            cout << aux2[i].S << " - " << aux[j].S << endl;
            cout << aux2[180503].F << " -- " << aux2[180504].F << endl;
          }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          // if(i < sz(aux2) - 1){
            // if(aux[j].F < aux2[i+1].F) continue;
            // if(j < sz(aux) - 1)
              // if(aux[j+1].F < aux2[i].F) continue;
          // }
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          if(a[1] == 189999) cout << aux2[j].S << " - " << aux2[i].S << endl;
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          // if(i < sz(aux2) - 1){
            // if(aux[j].F < aux2[i+1].F) continue;
            // if(j < sz(aux) - 1)
              // if(aux[j+1].F < aux2[i].F) continue;
          // }
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          if(a[1] == 189999){
            cout << aux2[i].S << " - " << aux[j].S << endl;
            cout << aux2[180504].F << " -- " << aux2[180505].F << endl;
          }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }

  int pos = -1;

  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      pos = i;
      break;
    }
  }

  if(pos != -1){
    bool att = false;
    for(int i=0;i<sz(aux);i++){
      if(pos){
        if(aux[i].F < aux2[pos-1].F){
          at[aux2[pos].S] = 0;
          at[aux[i].S] = 1;
          att = true;
          break;
        }
      }
    }

    if(att){
      if(a[1] == 189999){
        cout << "pos : " << pos << endl;
      }
      cout << "YES" << endl;
      for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
      cout << endl;
      exit(0);
    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  // if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i-1].F){
          if(i < (sz(aux2) - 1)){
            if(aux[j].F <= aux2[i+1].F) continue;
          }
            // if(j < sz(aux) - 1)
            //   if(aux[j+1].F <= aux2[i].F) continue;
          at[aux[j].S] = 1;
          at[aux2[i].S] = 0;

          // if(a[1] == 189999){
          //   cout << "I : " << i << endl;
          //   cout << aux2[i].S << " - " << aux[j].S << endl;
          //   cout << aux2[180503].F << " -- " << aux2[180504].F << endl;
          // }
          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;
          exit(0);
        }
      }

    }
  }
  if(a[1] == 189999) cout << 1 << endl;
  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  if(a[1] == 189999) cout << "eae" << endl;
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define MAXN (int)(2*1e5 + 10)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n;
int a[MAXN], b[MAXN], f[MAXN];

int at[MAXN];

void tenta(vector<int> inc, vector<int> dec){

  vector<pair<int, int> > aux, aux2;

  for(int i=1;i<=n;i++){
    if(at[i]){
      aux.push_back({a[i], i});
    } else {
      aux2.push_back({a[i], i});
    }
  }

  int cont = 0;
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F) cont++;
  }

  if(cont >= 2){
    cout << "NO" << endl;
    exit(0);
  }
  for(int i=1;i<sz(aux2);i++){
    if(aux2[i].F >= aux2[i-1].F){
      for(int j=0;j<sz(aux);j++){
        if(aux[j].F < aux2[i].F and aux[j].S > aux2[i].S){
          at[aux[j].S] = 1;
          // at[aux2[i-1].S] = 0;

          cout << "YES" << endl;
          for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1) << " ";
          cout << endl;

          exit(0);
        }
      }

    }
  }

  cout << "NO" << endl;
  exit(0);
}

void LIS(){
  int ans = 0;
  for(int i=1;i<=n;i++){
    f[i] = lower_bound(b+1, b+ans+1, a[i]) - b;
    ans = max(ans, f[i]);
    b[f[i]] = a[i];
  }

  int require = ans;
  vector<int> anss;
  for(int i=n;i>=1;i--){
    if(f[i] == require) anss.push_back(a[i]), require--;
  }
  reverse(anss.begin(), anss.end());
  vector<int> anss2;
  int pos = 0;
  for(int i=1;i<=n;i++){
    if(pos < sz(anss)){
      if(a[i] == anss[pos]){
        at[i] = 1;
        pos++;
      } else anss2.push_back(a[i]);
    } else anss2.push_back(a[i]);
  }

  // for(auto i : anss) cout << i << " ";
  // cout << endl;

  for(int i=1;i<sz(anss2);i++){
    if(anss2[i] >= anss2[i-1]){
      tenta(anss, anss2);
      break;
    }
  }
  cout << "YES" << endl;
  for(int i=1;i<=n;i++) cout << (at[i] == 1 ? 0 : 1)<< " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // int c = 0;
  // int aaa = 0;
  // for(int i=200000;i>=0;i--){
  //   if(c == 29) cout << aaa++ << " ", c = 0;
  //   else cout << i << " ";
  //   c++;
  // }

  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  LIS();

  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pi;
main() {
	int n;
	cin >> n;
	int a[n];
	pi dp[n][2];
	for (int &i : a) cin >> i;
	dp[0][0].first = 300000, dp[0][1].first = -1;
	for (int i = 1; i < n; ++i) {
		if (a[i] > a[i - 1] && a[i] > dp[i - 1][1].first) dp[i][0] = max(pi(dp[i - 1][0].first, 0), pi(a[i - 1], 1));
		else if (a[i] > a[i - 1]) dp[i][0] = pi(dp[i - 1][0].first, 0);
		else if (a[i] > dp[i - 1][1].first) dp[i][0] = pi(a[i - 1], 1);
		else dp[i][0].first = -1;
		if (a[i] < a[i - 1] && a[i] < dp[i - 1][0].first) dp[i][1] = min(pi(dp[i - 1][1].first, 1), pi(a[i - 1], 0));
		else if (a[i] < a[i - 1]) dp[i][1] = pi(dp[i - 1][1].first, 1);
		else if (a[i] < dp[i - 1][0].first) dp[i][1] = pi(a[i - 1], 0);
		else dp[i][1].first = 300000;
	}
	if (dp[n - 1][0].first > -1) {
		cout << "YES\n";
		a[n - 1] = 0;
		for (int i = n - 2, j = dp[n - 1][0].second; ~i; j = dp[i][j].second, --i) a[i] = j;
		for (int i : a) cout << i << ' ';
		return 0;
	}
	if (dp[n - 1][1].first < 300000) {
		cout << "YES\n";
		a[n - 1] = 1;
		for (int i = n - 2, j = dp[n - 1][0].second; ~i; j = dp[i][j].second, --i) a[i] = j;
		for (int i : a) cout << i << ' ';
		return 0;
	}
	cout << "NO";
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pi;
main() {
	int n;
	cin >> n;
	int a[n];
	pi dp[n][2];
	for (int &i : a) cin >> i;
	dp[0][0].first = 300000, dp[0][1].first = -1;
	for (int i = 1; i < n; ++i) {
		if (a[i] > a[i - 1] && a[i] > dp[i - 1][1].first) dp[i][0] = max(pi(dp[i - 1][0].first, 0), pi(a[i - 1], 1));
		else if (a[i] > a[i - 1]) dp[i][0] = pi(dp[i - 1][0].first, 0);
		else if (a[i] > dp[i - 1][1].first) dp[i][0] = pi(a[i - 1], 1);
		else dp[i][0].first = -1;
		if (a[i] < a[i - 1] && a[i] < dp[i - 1][0].first) dp[i][1] = min(pi(dp[i - 1][1].first, 1), pi(a[i - 1], 0));
		else if (a[i] < a[i - 1]) dp[i][1] = pi(dp[i - 1][1].first, 1);
		else if (a[i] < dp[i - 1][0].first) dp[i][1] = pi(a[i - 1], 0);
		else dp[i][1].first = 300000;
	}
	if (dp[n - 1][0].first > -1) {
		cout << "YES\n";
		a[n - 1] = 0;
		for (int i = n - 2, j = dp[n - 1][0].second; ~i; j = dp[i][j].second, --i) a[i] = j;
		for (int i : a) cout << i << ' ';
		return 0;
	}
	if (dp[n - 1][1].first < 300000) {
		cout << "YES\n";
		a[n - 1] = 1;
		for (int i = n - 2, j = dp[n - 1][1].second; ~i; j = dp[i][j].second, --i) a[i] = j;
		for (int i : a) cout << i << ' ';
		return 0;
	}
	cout << "NO";
}


#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define ones(x) __builtin_popcount(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define lbit(x) ((x)&(-(x)))
#define hbit(x) 1<<(31-__builtin_clz(x))

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

#define __seg_p (int _l, int _r, int val, int p=1, int l=0, int r=N)
#define __seg_out if (_r <= l || r <= _l)
#define __seg_in if (_l <= l && r <= _r)
#define __seg_one if (l+1 == r)
#define __seg_calc int m = (l+r)>>1, pl = p<<1, pr = p<<1|1;
#define __seg_l (_l, _r, val, pl, l, m)
#define __seg_r (_l, _r, val, pr, m, r)

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100005;
const int CF = 300005;

const int N = 2e5+5;

int n;
int a[N];

void gg(){
    cout << "NO" << endl;
    exit(0);
}

void solve() {
    cin >> n;
    FOR(i, 1, n+1)
        cin >> a[i];
    if (n == 1){
        cout << "YES\n";
        cout << "1"; return;
    }
    vi inc, dec;
    if (a[1] == a[2]){
        inc.pb(1);
        dec.pb(2);
    }else if(a[1] < a[2]){
        inc.pb(1); inc.pb(2);
    }else{
        dec.pb(1); dec.pb(2);
    }
    int i = 3;
    while (i<=n){
        if (dec.empty()){
            int u = a[inc.back()];
            if (a[i] > u){
                inc.pb(i);
            }else{
                int dori = inc.back();
                inc.pop_back(); dec.pb(dori);
                continue;
            }
        }else if (inc.empty()){
            int d = a[dec.back()];
            if (a[i] < d){
                dec.pb(i);
            }else{
                int uori = dec.back();
                dec.pop_back(); inc.pb(uori);
                continue;
            }
        }else{
            int d = a[dec.back()], u = a[inc.back()];
            if (u < d){ // not crossed
                if (a[i] <= u){
                    dec.pb(i);
                }else if (a[i] >= d){
                    inc.pb(i);
                }else{ // in the middle
                    if (i == n){
                        inc.pb(i);
                    }else{
                        if (a[i+1] <= u){// give inc more free
                            dec.pb(i);  dec.pb(i+1);
                        }else if (a[i+1] >= d){// give dec more free
                            inc.pb(i);  inc.pb(i+1);
                        }else{
                            if (a[i] < a[i+1]){
                                inc.pb(i);  dec.pb(i+1);
                            }else{
                                dec.pb(i);  inc.pb(i+1);
                            }
                        }
                        i++;
                    }
                }
            }else{//crossed
                if (a[i] < d){
                    dec.pb(i);
                }else if (a[i] > u){
                    inc.pb(i);
                }else{
                    gg();
                }
            }
        }
        i++;
    }

    char c[N];
    for (auto i: inc)
        c[i] = '0';
    for (auto i: dec)
        c[i] = '1';
    if (inc.empty())
        c[1] = '0';
    if (dec.empty())
        c[1] = '1';

    cout << "YES\n";
    FOR(i, 1, n+1)
        cout << c[i] << ' ';
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    solve();
    cout << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define ones(x) __builtin_popcount(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define lbit(x) ((x)&(-(x)))
#define hbit(x) 1<<(31-__builtin_clz(x))

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

#define __seg_p (int _l, int _r, int val, int p=1, int l=0, int r=N)
#define __seg_out if (_r <= l || r <= _l)
#define __seg_in if (_l <= l && r <= _r)
#define __seg_one if (l+1 == r)
#define __seg_calc int m = (l+r)>>1, pl = p<<1, pr = p<<1|1;
#define __seg_l (_l, _r, val, pl, l, m)
#define __seg_r (_l, _r, val, pr, m, r)

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100005;
const int CF = 300005;

const int N = 2e5+5;

int n;
int a[N];

void gg(){
    cout << "NO" << endl;
    exit(0);
}

void solve() {
    cin >> n;
    FOR(i, 1, n+1)
        cin >> a[i];
    if (n == 1){
        cout << "YES\n";
        cout << "1"; return;
    }
    vi inc, dec;
    if (a[1] == a[2]){
        inc.pb(1);
        dec.pb(2);
    }else if(a[1] < a[2]){
        inc.pb(1); inc.pb(2);
    }else{
        dec.pb(1); dec.pb(2);
    }
    int i = 3;
    while (i<=n){
        if (dec.empty()){
            int u = a[inc.back()];
            if (a[i] > u){
                inc.pb(i);
            }else{
                int dori = inc.back();
                inc.pop_back(); dec.pb(dori);
                continue;
            }
        }else if (inc.empty()){
            int d = a[dec.back()];
            if (a[i] < d){
                dec.pb(i);
            }else{
                int uori = dec.back();
                dec.pop_back(); inc.pb(uori);
                continue;
            }
        }else{
            int d = a[dec.back()], u = a[inc.back()];
            if (u < d){ // not crossed
                if (a[i] <= u){
                    dec.pb(i);
                }else if (a[i] >= d){
                    inc.pb(i);
                }else{ // in the middle
                    if (i == n){
                        inc.pb(i);
                    }else{
                        if (a[i+1] <= u){
                            dec.pb(i+1);  inc.pb(i);
                        }else if (a[i+1] >= d){
                            inc.pb(i+1);  dec.pb(i);
                        }else{
                            if (a[i] < a[i+1]){
                                inc.pb(i);  dec.pb(i+1);
                            }else{
                                dec.pb(i);  inc.pb(i+1);
                            }
                        }
                        i++;
                    }
                }
            }else{//crossed
                if (a[i] < d){
                    dec.pb(i);
                }else if (a[i] > u){
                    inc.pb(i);
                }else{
                    gg();
                }
            }
        }
        i++;
    }

    char c[N];
    for (auto i: inc)
        c[i] = '0';
    for (auto i: dec)
        c[i] = '1';
    if (inc.empty())
        c[1] = '0';
    if (dec.empty())
        c[1] = '1';

    cout << "YES\n";
    FOR(i, 1, n+1)
        cout << c[i] << ' ';
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    solve();
    cout << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define ones(x) __builtin_popcount(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define lbit(x) ((x)&(-(x)))
#define hbit(x) 1<<(31-__builtin_clz(x))

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

#define __seg_p (int _l, int _r, int val, int p=1, int l=0, int r=N)
#define __seg_out if (_r <= l || r <= _l)
#define __seg_in if (_l <= l && r <= _r)
#define __seg_one if (l+1 == r)
#define __seg_calc int m = (l+r)>>1, pl = p<<1, pr = p<<1|1;
#define __seg_l (_l, _r, val, pl, l, m)
#define __seg_r (_l, _r, val, pr, m, r)

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100005;
const int CF = 300005;

const int N = 2e5+5;

int n;
int a[N];

void gg(){
    cout << "NO" << endl;
    exit(0);
}

void solve() {
    cin >> n;
    FOR(i, 1, n+1)
        cin >> a[i];
    if (n == 1){
        cout << "YES\n";
        cout << "1"; return;
    }
    vi inc, dec;
    if (a[1] == a[2]){
        inc.pb(1);
        dec.pb(2);
    }else if(a[1] < a[2]){
        inc.pb(1); inc.pb(2);
    }else{
        dec.pb(1); dec.pb(2);
    }
    int i = 3;
    while (i<=n){
        if (dec.empty()){
            int u = a[inc.back()];
            if (a[i] > u){
                inc.pb(i);
            }else{
                int dori = inc.back();
                inc.pop_back(); dec.pb(dori);
                continue;
            }
        }else if (inc.empty()){
            int d = a[dec.back()];
            if (a[i] < d){
                dec.pb(i);
            }else{
                int uori = dec.back();
                dec.pop_back(); inc.pb(uori);
                continue;
            }
        }else{
            int d = a[dec.back()], u = a[inc.back()];
            if (u < d){ // not crossed
                if (a[i] <= u){
                    dec.pb(i);
                }else if (a[i] >= d){
                    inc.pb(i);
                }else{ // in the middle
                    if (i == n){
                        inc.pb(i);
                    }else{
                        if (a[i+1] <= u){// give inc more free
                            dec.pb(i);  dec.pb(i+1);
                        }else if (a[i+1] >= d){// give dec more free
                            inc.pb(i);  inc.pb(i+1);
                        }else{
                            if (a[i] < a[i+1]){
                                inc.pb(i); // al least
                            }else {
                                dec.pb(i);
                            }
                            i--;
                        }
                        i++;
                    }
                }
            }else{//crossed
                if (a[i] < d){
                    dec.pb(i);
                }else if (a[i] > u){
                    inc.pb(i);
                }else{
                    gg();
                }
            }
        }
        i++;
    }

    char c[N];
    for (auto i: inc)
        c[i] = '0';
    for (auto i: dec)
        c[i] = '1';
    if (inc.empty())
        c[1] = '0';
    if (dec.empty())
        c[1] = '1';

    cout << "YES\n";
    FOR(i, 1, n+1)
        cout << c[i] << ' ';
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    solve();
    cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// 3 1 2 4

// 3
// 1 2 4
// 3 2
// 1 4

//a b x y
// a
// b
const int maxn =  2e5+1000;
int n;
int a[maxn];
int ans[maxn];
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;

	rep(i,0,n) cin >> a[i];
	if(n == 1)
	{
		cout << "YES" << endl << 1 << endl;
		return 0;
	}
	int in = 0,de = maxn;
	if(a[0] > a[1])
	{
		de = a[0];
		ans[0] = 1;
	}
	else
	{
		in = a[0];
		ans[0] = 0;
	}
	int f = 0;
	rep(i,1,n)
	{
		if(a[i]>in && a[i] < de)
		{
			if(a[i] < a[i]+1)
			{
				in = a[i];
				ans[i] = 0;
			}
			else
			{
				de = a[i];
				ans[i] = 1;
			}
		}
		else if(a[i] > in)
		{
			in = a[i];
			ans[i] = 0;
		}
		else if(a[i] < de)
		{
			de = a[i];
			ans[i] = 1;
		}
		else
		{
			f = 1;
		}
	}
	if(f)
	{
		cout << "NO" << endl;
		return 0;
	}
	else
	{
		cout << "YES" << endl;
		rep(i,0,n) cout << ans[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// 3 1 2 4

// 3
// 1 2 4
// 3 2
// 1 4

//a b x y
// a
// b
const int maxn =  2e5+1000;
int n;
int a[maxn];
int ans[maxn];
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;

	rep(i,0,n) cin >> a[i];
	if(n == 1)
	{
		cout << "YES" << endl << 1 << endl;
		return 0;
	}
	int in = -1,de = maxn;
	if(a[0] > a[1])
	{
		de = a[0];
		ans[0] = 1;
	}
	else
	{
		in = a[0];
		ans[0] = 0;
	}
	int f = 0;
	rep(i,1,n)
	{
		if(a[i]>in && a[i] < de)
		{
			if(a[i] < a[i+1])
			{
				in = a[i];
				ans[i] = 0;
			}
			else
			{
				de = a[i];
				ans[i] = 1;
			}
		}
		else if(a[i] > in)
		{
			in = a[i];
			ans[i] = 0;
		}
		else if(a[i] < de)
		{
			de = a[i];
			ans[i] = 1;
		}
		else
		{
			f = 1;
			// cout << i << endl;
		}
	}
	if(f)
	{
		cout << "NO" << endl;
		return 0;
	}
	else
	{
		cout << "YES" << endl;
		rep(i,0,n) cout << ans[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// 3 1 2 4

// 3
// 1 2 4
// 3 2
// 1 4

//a b x y
// a
// b
const int maxn =  2e5+1000;
int n;
int a[maxn];
int ans[maxn];
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;

	rep(i,0,n) cin >> a[i];
	if(n == 1)
	{
		cout << "YES" << endl << 1 << endl;
		return 0;
	}
	int in = 0,de = maxn;
	if(a[0] > a[1])
	{
		de = a[0];
		ans[0] = 1;
	}
	else
	{
		in = a[0];
		ans[0] = 0;
	}
	int f = 0;
	rep(i,1,n)
	{
		if(a[i]>in && a[i] < de)
		{
			if(a[i] < a[i+1])
			{
				in = a[i];
				ans[i] = 0;
			}
			else
			{
				de = a[i];
				ans[i] = 1;
			}
		}
		else if(a[i] > in)
		{
			in = a[i];
			ans[i] = 0;
		}
		else if(a[i] < de)
		{
			de = a[i];
			ans[i] = 1;
		}
		else
		{
			f = 1;
		}
	}
	if(f)
	{
		cout << "NO" << endl;
		return 0;
	}
	else
	{
		cout << "YES" << endl;
		rep(i,0,n) cout << ans[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int inf = 0x3f3f3f3f;
int n, a[maxn], ins = -inf, des = inf;
bool vis[maxn];

int main() {
    scanf("%d", &n);
    for (int i=1; i<=n; ++i)
        scanf("%d", a+i);
    for (int i=1; i<=n; ++i) {
        if(ins>=a[i] && a[i]>=des)
            return puts("NO"),0;
        if(ins<a[i] && a[i]<des) {
            if(i==n) vis[i] = 1;
            else if(a[i]<a[i+1]) ins = a[i];
            else des = a[i], vis[i] = 1;
        } else if(des>a[i]) {
            vis[i]=1, des=a[i];
        } else if(ins<a[i])
            ins = a[i];
        else break;
    }
    puts("YES");
    for (int i=1; i<=n; ++i)
        printf("%d ", vis[i]);
    puts("");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int de[maxn], p1, inc[maxn], p2;
bool vis[maxn];
int n, a[maxn];

int main() {
    scanf("%d", &n);
    for (int i=1; i<=n; ++i)
        scanf("%d", a+i);
    for (int i=1; i<=n; ++i) {
        if(de[p1]>a[i] && a[i]>inc[p2]) {
            if(a[i]<a[i+1]) {
                inc[++p2] = a[i];
                de[++p1] = a[++i];
                vis[i] = 1;
            }
            else {
                de[++p1] = a[i], vis[i]=1;
                inc[++p2] = a[++i];
            }
        } else if((!p1 && a[i]>a[i+1])||de[p1]>a[i]) {
            de[++p1]=a[i], vis[i]=1;
        } else if((!p2 && a[i]<a[i+1])||inc[p2]<a[i]) {
            inc[++p2]=a[i];
        } else {
//            puts("-1");
            return puts("NO"),0;
        }
    }
    puts("YES");
    for (int i=1; i<=n; ++i)
        printf("%d ", vis[i]);
    puts("");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int de[maxn], p1, inc[maxn], p2;
bool vis[maxn];
int n, a[maxn];

int main() {
    scanf("%d", &n);
    for (int i=1; i<=n; ++i)
        scanf("%d", a+i);
    for (int i=1; i<=n; ++i) {
        if(de[p1]>a[i] && a[i]>inc[p2]) {
            if(a[i]<a[i+1])  inc[++p2] = a[i];
            else de[++p1] = a[i], vis[i]=1;
        } else if((!p1 && a[i]>a[i+1])||(de[p1]>a[i] )) {
            de[++p1]=a[i], vis[i]=1;
        } else if((!p2 && a[i]<a[i+1])||inc[p2]<a[i]) {
            inc[++p2]=a[i];
        } else {
//            puts("-1");
            return puts("NO"),0;
        }
    }
    puts("YES");
//    for (int i=1; i<=p1; ++i) printf("%d ", de[i]);
//    puts("");
//    for (int i=1; i<=p2; ++i) printf("%d ", inc[i]);
//    puts("");
    for (int i=1; i<=n; ++i)
        printf("%d ", vis[i]);
    puts("");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int de[maxn], p1, inc[maxn], p2;
bool vis[maxn];
int n, a[maxn];

int main() {
    scanf("%d", &n);
    for (int i=1; i<=n; ++i)
        scanf("%d", a+i);
    for (int i=1; i<=n; ++i) {
        if(de[p1]>a[i] && a[i]>inc[p2]) {
            if(a[i]<a[i+1]) {
                inc[++p2] = a[i];
                de[++p1] = a[++i];
                vis[i] = 1;
            }
            else {
                de[++p1] = a[i], vis[i]=1;
                inc[++p2] = a[++i];
            }
        } else if(!p1||de[p1]>a[i]) {
            de[++p1]=a[i], vis[i]=1;
        } else if(!p2||inc[p2]<a[i]) {
            inc[++p2]=a[i];
        } else {
//            puts("-1");
            return puts("NO"),0;
        }
    }
    puts("YES");
    for (int i=1; i<=n; ++i)
        printf("%d ", vis[i]);
    puts("");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define  INF 0x3f3f3f3f
const int N=2e5+5;
int a[N];
int main()
{
    int n;
    cin>>n;
    int up=-1;
    int down=INF;
    for(int i=0;i<n;i++)
    {

        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]>up&&a[i]<down)
        {
            if(a[i]<a[i+1])
            {
                up=a[i];
                a[i]=0;
            }
            else
            {
                down=a[i];
                a[i]=1;
            }
        }
        else if(a[i]>up)
        {
            up=a[i];
            a[i]=0;
        }
        else if(a[i]<down)
        {
            down=a[i];
            a[i]=1;
        }
        else
        {
            puts("NO");
            return 0;
        }
    }
     puts("YES");
    for(int i=0;i<n;i++)
    {

        printf("%d ",a[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define  INF 0x3f3f3f3f
const int N=2e5+5;
int a[N];
int main()
{
    int n;
    cin>>n;
    int up=-1;
    int down=INF;
    for(int i=0;i<n;i++)
    {

        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]>up&&a[i]<down)
        {
            if(a[i]<a[i+1])
            {
                up=a[i];
                a[i]=0;
            }
            else
            {
                down=a[i];
                a[i]=1;
            }
        }
        else if(a[i]>up)
        {
            up=a[i];
            a[i]=0;
        }
        else if(a[i]<down)
        {
            down=a[i];
            a[i]=1;
        }
        else
        {
            puts("NO");
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        printf("%d ",a[i]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
//    freopen("../in", "r", stdin);
//    freopen("../out", "w", stdout);

    int n;
    cin >> n;
    vector<int> arr, inc, dec, cnt(n);

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        arr.push_back(t);
    }

    for (int i = 0; i < n; i++) {
        bool inc_flag = false;
        bool dec_flag = false;

        if (inc.empty())
            inc_flag = true;
        else {
            inc_flag = (arr[i] > inc[inc.size() - 1]);
        }
        if (dec.empty())
            dec_flag = true;
        else {
            dec_flag = (arr[i] < dec[dec.size() - 1]);
        }
        if (inc_flag && dec_flag) {
            if (i < n - 1 && arr[i + 1] > arr[i]) {
                inc.push_back(arr[i]);
                cnt[i] = 0;
            } else {
                dec.push_back(arr[i]);
                cnt[i] = 1;
            }
        } else if (inc_flag && !dec_flag) {
            inc.push_back(arr[i]);
            cnt[i] = 0;
        } else if (!inc_flag && dec_flag) {
            dec.push_back(arr[i]);
            cnt[i] = 1;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
        if (i != 0)cout << " ";
        cout << cnt[i];
    }

}


#include <bits/stdc++.h>

using namespace std;

int main() {
//    freopen("../in", "r", stdin);
//    freopen("../out", "w", stdout);

    int n;
    cin >> n;
    vector<int> arr, inc, dec, cnt(n);

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        arr.push_back(t);
    }

    for (int i = 0; i < n; i++) {
        bool inc_flag = false;
        bool dec_flag = false;

        if (inc.empty())
            inc_flag = true;
        else {
            inc_flag = (arr[i] > inc[inc.size() - 1]);
        }
        if (dec.empty())
            dec_flag = true;
        else {
            dec_flag = (arr[i] < dec[dec.size() - 1]);
        }
        if (inc_flag && dec_flag) {
            if (i < n - 1 && arr[i + 1] > arr[i]) {
                inc.push_back(arr[i]);
                cnt[i] = 0;
            } else {
                dec.push_back(arr[i]);
                cnt[i] = 1;
            }
        } else if (inc_flag) {
            inc.push_back(arr[i]);
            cnt[i] = 0;
        } else if (dec_flag) {
            dec.push_back(arr[i]);
            cnt[i] = 1;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
        if (i != 0)cout << " ";
        cout << cnt[i];
    }

}


#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct info{
	int k, l, r;
};

struct SegT {
private:
	int sz; vector<int> nodema, nodemi;
	const int init_ma = -mod, init_mi = mod;
public:
	SegT(vector<int> ori) {
		int n = ori.size();
		sz = 1;
		while (sz < n)sz *= 2;
		nodema.resize(2 * sz - 1, init_ma);
		nodemi.resize(2 * sz - 1, init_mi);
		rep(i, n) {
			nodema[i + sz - 1] = nodemi[i + sz - 1] = ori[i];
		}
		per(i, sz - 1) {
			nodema[i] = maf(nodema[2*i+1], nodema[2 * i + 2]);
			nodemi[i] = mif(nodemi[2 * i + 1], nodemi[2 * i + 2]);
		}
	}
	int maf(int a, int b) {
		return max(a, b);
	}
	int mif(int a,int b){
		return min(a, b);
	}
	int find_id_ma(int i,int x) {
		if (nodema[i + sz - 1] >= x)return i;
		int k = 0, l = 0, r = sz;
		stack<info> st;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (mid > i) {
				st.push({ 2 * k+2,mid,r });
				k = 2 * k + 1; r = mid;
			}
			else {
				k = 2 * k + 2; l=mid;
			}
		}
		k = -1;
		while (!st.empty()) {
			info in = st.top(); st.pop();
			if (nodema[in.k] >= x) {
				k = in.k, l = in.l; r = in.r;
				break;
			}
		}
		if (k < 0)return sz;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (nodema[2 * k + 1] >= x) {
				k = 2 * k + 1, r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		return k - sz + 1;
	}
	int find_id_mi(int i, int x) {
		if (nodemi[i + sz - 1] <= x)return i;
		int k = 0, l = 0, r = sz;
		stack<info> st;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (mid > i) {
				st.push({ 2 * k + 2,mid,r });
				k = 2 * k + 1; r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		k = -1;
		while (!st.empty()) {
			info in = st.top(); st.pop();
			if (nodemi[in.k] <= x) {
				k = in.k, l = in.l; r = in.r;
				break;
			}
		}
		if (k < 0)return sz;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (nodemi[2 * k + 1] <= x) {
				k = 2 * k + 1, r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		return k - sz + 1;
	}
};
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	SegT st(a);
	vector<int> up(n), down(n);
	//up
	per(i, n) {
		int nex = st.find_id_ma(i + 1, a[i] + 1);
		if (nex >= n) {
			up[i] = 1;
		}
		else {
			up[i] = up[nex] + 1;
		}
		nex = st.find_id_mi(i + 1, a[i]-1);
		if (nex >= n) {
			down[i] = 1;
		}
		else {
			down[i] = down[nex] + 1;
		}
	}
	vector<P> v; v.push_back({ -mod,mod });
	function<bool(int,int,int)> judge=[&](int i,int u,int d)->bool {
		int sum = 0;
		int uid = st.find_id_ma(i + 1, u + 1);
		if (uid < n)sum += up[uid];
		int did = st.find_id_mi(i + 1, d - 1);
		if (did < n)sum += down[did];
		//cout << i << " " << u << " " << d << " " << uid << " " << did << " " << endl;
		return n - 1 - i == sum;
	};
	function<void(int, int, int)> ans = [&](int i, int u, int d) {

		cout << "YES" << endl;
		rep(j, n) {
			if (j > 0)cout << " ";
			if (j < i) {
				if (a[j] <= u) {
					cout << 0;
				}
				else {
					cout << 1;
				}
			}
			else if (j == i) {
				if (a[j] <= u) {
					d = a[j];
					cout << 1;
				}
				else if (a[j] >= d) {
					u = a[j];
					cout << 0;
				}
			}
			else {
				if (a[j] <= u)cout << 1;
				else cout << 0;
			}
		}
		cout << endl;
	};
	rep(i, n) {
		vector<P> nex;
		rep(j, v.size()) {
			if (a[i] <= v[j].first) {
				if (judge(i, v[j].first, a[i])) {
					//cout << i << " " << v[j].first << " " << v[j].second << endl;
					ans(i, v[j].first, v[j].second);
					return;
				}
				else continue;
			}
			else if (a[i] >= v[j].second) {
				if (judge(i, a[i], v[j].second)) {
					//cout << i << " " << v[j].first << " " << v[j].second << endl;
					ans(i, v[j].first, v[j].second);
					return;
				}
				else continue;
			}
			else {
				nex.push_back({ v[j].first,a[i] });
				nex.push_back({ a[i],v[j].second });
			}
		}
		swap(v, nex);
	}
	if (!v.empty()) {
		ans(n, v[0].first, v[1].first);
	}
	cout << "NO" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct info{
	int k, l, r;
};

struct SegT {
private:
	int sz; vector<int> nodema, nodemi;
	const int init_ma = -mod, init_mi = mod;
public:
	SegT(vector<int> ori) {
		int n = ori.size();
		sz = 1;
		while (sz < n)sz *= 2;
		nodema.resize(2 * sz - 1, init_ma);
		nodemi.resize(2 * sz - 1, init_mi);
		rep(i, n) {
			nodema[i + sz - 1] = nodemi[i + sz - 1] = ori[i];
		}
		per(i, sz - 1) {
			nodema[i] = maf(nodema[2*i+1], nodema[2 * i + 2]);
			nodemi[i] = mif(nodemi[2 * i + 1], nodemi[2 * i + 2]);
		}
	}
	int maf(int a, int b) {
		return max(a, b);
	}
	int mif(int a,int b){
		return min(a, b);
	}
	int find_id_ma(int i,int x) {
		if (i == sz)return sz;
		if (nodema[i + sz - 1] >= x)return i;
		int k = 0, l = 0, r = sz;
		stack<info> st;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (mid > i) {
				st.push({ 2 * k+2,mid,r });
				k = 2 * k + 1; r = mid;
			}
			else {
				k = 2 * k + 2; l=mid;
			}
		}
		k = -1;
		while (!st.empty()) {
			info in = st.top(); st.pop();
			if (nodema[in.k] >= x) {
				k = in.k, l = in.l; r = in.r;
				break;
			}
		}
		if (k < 0)return sz;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (nodema[2 * k + 1] >= x) {
				k = 2 * k + 1, r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		return k - sz + 1;
	}
	int find_id_mi(int i, int x) {
		if (i == sz)return sz;
		if (nodemi[i + sz - 1] <= x)return i;
		int k = 0, l = 0, r = sz;
		stack<info> st;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (mid > i) {
				st.push({ 2 * k + 2,mid,r });
				k = 2 * k + 1; r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		k = -1;
		while (!st.empty()) {
			info in = st.top(); st.pop();
			if (nodemi[in.k] <= x) {
				k = in.k, l = in.l; r = in.r;
				break;
			}
		}
		if (k < 0)return sz;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (nodemi[2 * k + 1] <= x) {
				k = 2 * k + 1, r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		return k - sz + 1;
	}
};
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	SegT st(a);
	vector<int> up(n), down(n);
	//up
	per(i, n) {
		int nex = st.find_id_ma(i + 1, a[i] + 1);
		if (nex >= n) {
			up[i] = 1;
		}
		else {
			up[i] = up[nex] + 1;
		}
		nex = st.find_id_mi(i + 1, a[i]-1);
		if (nex >= n) {
			down[i] = 1;
		}
		else {
			down[i] = down[nex] + 1;
		}
	}
	vector<P> v; v.push_back({ -mod,mod });
	function<bool(int,int,int)> judge=[&](int i,int u,int d)->bool {
		int sum = 0;
		int uid = st.find_id_ma(i + 1, u + 1);
		if (uid < n)sum += up[uid];
		int did = st.find_id_mi(i + 1, d - 1);
		if (did < n)sum += down[did];
		//cout << i << " " << u << " " << d << " " << uid << " " << did << " " << endl;
		return n - 1 - i == sum;
	};
	function<void(int, int, int)> ans = [&](int i, int u, int d) {

		cout << "YES" << endl;
		rep(j, n) {
			if (j > 0)cout << " ";
			if (j < i) {
				if (a[j] <= u) {
					cout << 0;
				}
				else {
					cout << 1;
				}
			}
			else if (j == i) {
				if (a[j] <= u) {
					d = a[j];
					cout << 1;
				}
				else if (a[j] >= d) {
					u = a[j];
					cout << 0;
				}
			}
			else {
				if (a[j] <= u)cout << 1;
				else cout << 0;
			}
		}
		cout << endl;
	};
	rep(i, n) {
		vector<P> nex;
		rep(j, v.size()) {
			if (a[i] <= v[j].first) {
				if (judge(i, v[j].first, a[i])) {
					//cout << i << " " << v[j].first << " " << v[j].second << endl;
					ans(i, v[j].first, v[j].second);
					return;
				}
				else continue;
			}
			else if (a[i] >= v[j].second) {
				if (judge(i, a[i], v[j].second)) {
					//cout << i << " " << v[j].first << " " << v[j].second << endl;
					ans(i, v[j].first, v[j].second);
					return;
				}
				else continue;
			}
			else {
				nex.push_back({ v[j].first,a[i] });
				nex.push_back({ a[i],v[j].second });
			}
		}
		swap(v, nex);
	}
	if (!v.empty()) {
		ans(n, v[0].first, v[1].first);
		return;
	}
	cout << "NO" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct info{
	int k, l, r;
};

struct SegT {
private:
	int sz; vector<int> nodema, nodemi;
	const int init_ma = -mod, init_mi = mod;
public:
	SegT(vector<int> ori) {
		int n = ori.size();
		sz = 1;
		while (sz < n)sz *= 2;
		nodema.resize(2 * sz - 1, init_ma);
		nodemi.resize(2 * sz - 1, init_mi);
		rep(i, n) {
			nodema[i + sz - 1] = nodemi[i + sz - 1] = ori[i];
		}
		per(i, sz - 1) {
			nodema[i] = maf(nodema[2*i+1], nodema[2 * i + 2]);
			nodemi[i] = mif(nodemi[2 * i + 1], nodemi[2 * i + 2]);
		}
	}
	int maf(int a, int b) {
		return max(a, b);
	}
	int mif(int a,int b){
		return min(a, b);
	}
	int find_id_ma(int i,int x) {
		if (i == sz)return sz;
		if (nodema[i + sz - 1] >= x)return i;
		int k = 0, l = 0, r = sz;
		stack<info> st;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (mid > i) {
				st.push({ 2 * k+2,mid,r });
				k = 2 * k + 1; r = mid;
			}
			else {
				k = 2 * k + 2; l=mid;
			}
		}
		k = -1;
		while (!st.empty()) {
			info in = st.top(); st.pop();
			if (nodema[in.k] >= x) {
				k = in.k, l = in.l; r = in.r;
				break;
			}
		}
		if (k < 0)return sz;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (nodema[2 * k + 1] >= x) {
				k = 2 * k + 1, r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		return k - sz + 1;
	}
	int find_id_mi(int i, int x) {
		if (i == sz)return sz;
		if (nodemi[i + sz - 1] <= x)return i;
		int k = 0, l = 0, r = sz;
		stack<info> st;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (mid > i) {
				st.push({ 2 * k + 2,mid,r });
				k = 2 * k + 1; r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		k = -1;
		while (!st.empty()) {
			info in = st.top(); st.pop();
			if (nodemi[in.k] <= x) {
				k = in.k, l = in.l; r = in.r;
				break;
			}
		}
		if (k < 0)return sz;
		while (k < sz - 1) {
			int mid = (l + r) / 2;
			if (nodemi[2 * k + 1] <= x) {
				k = 2 * k + 1, r = mid;
			}
			else {
				k = 2 * k + 2; l = mid;
			}
		}
		return k - sz + 1;
	}
};
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	SegT st(a);
	vector<int> up(n), down(n);
	//up
	per(i, n) {
		int nex = st.find_id_ma(i + 1, a[i] + 1);
		if (nex >= n) {
			up[i] = 1;
		}
		else {
			up[i] = up[nex] + 1;
		}
		nex = st.find_id_mi(i + 1, a[i]-1);
		if (nex >= n) {
			down[i] = 1;
		}
		else {
			down[i] = down[nex] + 1;
		}
	}
	vector<P> v; v.push_back({ -mod,mod });
	function<bool(int,int,int)> judge=[&](int i,int u,int d)->bool {
		int sum = 0;
		int uid = st.find_id_ma(i + 1, u + 1);
		if (uid < n)sum += up[uid];
		int did = st.find_id_mi(i + 1, d - 1);
		if (did < n)sum += down[did];
		//cout << i << " " << u << " " << d << " " << uid << " " << did << " " << endl;
		return n - 1 - i == sum;
	};
	function<void(int, int, int)> ans = [&](int i, int u, int d) {

		cout << "YES" << endl;
		rep(j, n) {
			if (j > 0)cout << " ";
			if (j < i) {
				if (a[j] <= u) {
					cout << 0;
				}
				else {
					cout << 1;
				}
			}
			else if (j == i) {
				if (a[j] <= u) {
					d = a[j];
					cout << 1;
				}
				else if (a[j] >= d) {
					u = a[j];
					cout << 0;
				}
			}
			else {
				if (a[j] <= u)cout << 1;
				else cout << 0;
			}
		}
		cout << endl;
	};
	rep(i, n) {
		vector<P> nex;
		rep(j, v.size()) {
			if (a[i] <= v[j].first) {
				if (judge(i, v[j].first, a[i])) {
					//cout << i << " " << v[j].first << " " << v[j].second << endl;
					ans(i, v[j].first, v[j].second);
					return;
				}
				else continue;
			}
			else if (a[i] >= v[j].second) {
				if (judge(i, a[i], v[j].second)) {
					//cout << i << " " << v[j].first << " " << v[j].second << endl;
					ans(i, v[j].first, v[j].second);
					return;
				}
				else continue;
			}
			else {
				nex.push_back({ v[j].first,a[i] });
				nex.push_back({ a[i],v[j].second });
			}
		}
		swap(v, nex);
	}
	if (!v.empty()) {
		ans(n, v[0].first, v[1].first);
	}
	cout << "NO" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define N 200005
int a[N], f[N], n, flag=0;
void dfs(int x, int inc, int dec){
	if(x==n){
		flag=1;
		return;
	}
	if(inc!=-1&&inc<a[x]){
		f[x]=0;
		dfs(x+1,a[x],dec);
		if(flag) return;
	}
	if(dec!=-1&&dec>a[x]){
		f[x]=1;
		dfs(x+1,inc,a[x]);
		if(flag) return;
	}
	if(inc==-1){
		f[x]=0;
		dfs(x+1,a[x],dec);
		if(flag) return;
	}
	if(dec==-1){
		f[x]=1;
		dfs(x+1,inc,a[x]);
		if(flag) return;
	}
}
int main()
{
	int i, p0, p1;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",&a[i]);
		if(flag) continue;
		if(f[a[i]]==2){
			flag=1;
			continue;
		}
		f[a[i]]++;
	}
	if(flag){
		printf("NO");
		return 0;
	}
	dfs(0,-1,-1);
	if(!flag) printf("NO");
	else{
		printf("YES\n");
		for(i=0;i<n;++i)
		printf("%d ",f[i]);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define N 200005
int a[N], f[N], n, flag=0;
void dfs(int x, int inc, int dec){
	if(x==n){
		flag=1;
		return;
	}
	if(inc==-1||inc<a[x]){
		f[x]=0;
		dfs(x+1,a[x],dec);
		if(flag) return;
	}
	if(dec==-1||dec>a[x]){
		f[x]=1;
		dfs(x+1,inc,a[x]);
		if(flag) return;
	}
}
int main()
{
	int i, p0, p1;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",&a[i]);
		if(flag) continue;
		if(f[a[i]]==2){
			flag=1;
			continue;
		}
		f[a[i]]++;
	}
	if(flag){
		printf("NO");
		return 0;
	}
	dfs(0,-1,-1);
	if(!flag) printf("NO");
	else{
		printf("YES\n");
		for(i=0;i<n;++i)
		printf("%d ",f[i]);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define N 200005
int a[N], f[N], n, flag=0;
void dfs(int x, int inc, int dec){
	if(x==n){
		flag=1;
		return;
	}
	if(inc==-1||inc<a[x]){
		f[x]=0;
		dfs(x+1,a[x],dec);
		if(flag) return;
	}
	if(dec==-1||dec>a[x]){
		f[x]=1;
		dfs(x+1,inc,a[x]);
		if(flag) return;
	}
}
int main()
{
	int i, p0, p1;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",&a[i]);
	}
	dfs(0,-1,-1);
	if(!flag) printf("NO");
	else{
		printf("YES\n");
		for(i=0;i<n;++i)
		printf("%d ",f[i]);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define N 200005
int a[N], f[N], vis[N], n, flag=0;
int inc[N], de[N], cnt1, cnt2;
int main()
{
	int i, p0, p1;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",&a[i]);
		if(flag) continue;
		if(f[a[i]]==2){
			flag=1;
			continue;
		}
		f[a[i]]++;
	}
	if(flag){
		printf("NO");
		return 0;
	}
	inc[0]=-1;
	de[0]=N<<1;
	cnt1=cnt2=0;
	int now, nxt;
	for(i=0;i<n;++i){
		now=a[i];
		if(now<=inc[cnt1]&&now>=de[cnt2]){
			flag=1;
			break;
		}
		if(now>inc[cnt1]&&now<de[cnt2]){
			if(i==n-1) vis[i]=1;
			else{
				nxt=a[i+1];
				if(now<=nxt){
					inc[++cnt1]=now;
				}else{
					de[++cnt2]=now;
					vis[i]=1;
				}
			}
		}else if(now>inc[cnt1]){
			inc[++cnt1]=now;
		}else if(now<de[cnt2]){
			de[++cnt2]=now;
			vis[i]=1;
		}
	}
	if(flag){
		printf("NO\n");
	}else{
		printf("YES\n");
		for(i=0;i<n;++i){
			printf("%d ",vis[i]);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> int2;
#define pp(a,b) push_back(make_pair((a),(b)))
#define pb push_back
#define mp make_pair
#define buybuy {printf("-1\n");return 0;}
#define PI 3.141592653589

int next() {int x; cin >> x; return x;}
lint lnext() {lint x; cin >> x; return x;}
//template<typename T> outln(T x) {cout << x; cout << "\n";}
#define prt(a) cout << a << endl;
#define prtn(a, n) {for(int iiiiiiiiiii = 0; iiiiiiiiiii < n; iiiiiiiiiii++) cout << a[iiiiiiiiiii] << " "; cout << endl;}
#define prtall(a) {for (auto iiiiiiiiiii : a) cout << iiiiiiiiiii << " "; cout << endl;}

int main() {
	cout.precision(20);
	ios_base::sync_with_stdio(false);

	int n = next();
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = next();

	vector<int> down = {100001};
	vector<int> up = {-1};

	vector<bool> is_up(n);

	bool ok = true;

	for (int i = 0; i < n && ok; i++) {
		if (down.back() <= a[i] && up.back() >= a[i]) ok = false;
		else if (down.back() <= a[i]) {
			up.pb(a[i]);
			is_up[i] = true;
		} else if (up.back() >= a[i]) {
			down.pb(a[i]);
			is_up[i] = false;
		} else {
			if (i < n - 1) {
				if (a[i] == a[i + 1]) {
					up.pb(a[i]);
					down.pb(a[i + 1]);

					is_up[i] = true;
					is_up[i + 1] = false;
				} else if (a[i] > a[i + 1]) {
					down.pb(a[i]);
					is_up[i] = false;
				} else {
					up.pb(a[i]);
					is_up[i] = true;
				}
			}
		}
	}

	if (ok) {
		cout << "YES\n";
		for (int i = 0; i < n; i++) cout << 1 - is_up[i] << " ";
	} else {
		cout << "NO\n";
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> int2;
#define pp(a,b) push_back(make_pair((a),(b)))
#define pb push_back
#define mp make_pair
#define buybuy {printf("-1\n");return 0;}
#define PI 3.141592653589

int next() {int x; cin >> x; return x;}
lint lnext() {lint x; cin >> x; return x;}
//template<typename T> outln(T x) {cout << x; cout << "\n";}
#define prt(a) cout << a << endl;
#define prtn(a, n) {for(int iiiiiiiiiii = 0; iiiiiiiiiii < n; iiiiiiiiiii++) cout << a[iiiiiiiiiii] << " "; cout << endl;}
#define prtall(a) {for (auto iiiiiiiiiii : a) cout << iiiiiiiiiii << " "; cout << endl;}

int main() {
	cout.precision(20);
	ios_base::sync_with_stdio(false);

	int n = next();
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = next();

	vector<int> down = {200001};
	vector<int> up = {-1};

	vector<bool> is_up(n);

	bool ok = true;

	for (int i = 0; i < n && ok; i++) {
		if (down.back() <= a[i] && up.back() >= a[i]) ok = false;
		else if (down.back() <= a[i]) {
			up.pb(a[i]);
			is_up[i] = true;
		} else if (up.back() >= a[i]) {
			down.pb(a[i]);
			is_up[i] = false;
		} else {
			if (i < n - 1) {
				if (a[i] == a[i + 1]) {
					up.pb(a[i]);
					down.pb(a[i + 1]);

					is_up[i] = true;
					is_up[i + 1] = false;
				} else if (a[i] > a[i + 1]) {
					down.pb(a[i]);
					is_up[i] = false;
				} else {
					up.pb(a[i]);
					is_up[i] = true;
				}
			} else {
				down[i].pb(a[i]);
				is_up[i] = false;
			}
		}
	}

	if (ok) {
		cout << "YES\n";
		for (int i = 0; i < n; i++) cout << 1 - is_up[i] << " ";
	} else {
		cout << "NO\n";
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> int2;
#define pp(a,b) push_back(make_pair((a),(b)))
#define pb push_back
#define mp make_pair
#define buybuy {printf("-1\n");return 0;}
#define PI 3.141592653589

int next() {int x; cin >> x; return x;}
lint lnext() {lint x; cin >> x; return x;}
//template<typename T> outln(T x) {cout << x; cout << "\n";}
#define prt(a) cout << a << endl;
#define prtn(a, n) {for(int iiiiiiiiiii = 0; iiiiiiiiiii < n; iiiiiiiiiii++) cout << a[iiiiiiiiiii] << " "; cout << endl;}
#define prtall(a) {for (auto iiiiiiiiiii : a) cout << iiiiiiiiiii << " "; cout << endl;}

int main() {
	cout.precision(20);
	ios_base::sync_with_stdio(false);

	int n = next();
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = next();

	vector<int> down = {200001};
	vector<int> up = {-1};

	vector<bool> is_up(n);

	bool ok = true;

	for (int i = 0; i < n && ok; i++) {
		if (down.back() <= a[i] && up.back() >= a[i]) ok = false;
		else if (down.back() <= a[i]) {
			up.pb(a[i]);
			is_up[i] = true;
		} else if (up.back() >= a[i]) {
			down.pb(a[i]);
			is_up[i] = false;
		} else {
			if (i < n - 1) {
				if (a[i] == a[i + 1]) {
					up.pb(a[i]);
					down.pb(a[i + 1]);

					is_up[i] = true;
					is_up[i + 1] = false;
				} else if (a[i] > a[i + 1]) {
					down.pb(a[i]);
					is_up[i] = false;
				} else {
					up.pb(a[i]);
					is_up[i] = true;
				}
			}
		}
	}

	if (ok) {
		cout << "YES\n";
		for (int i = 0; i < n; i++) cout << 1 - is_up[i] << " ";
	} else {
		cout << "NO\n";
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> int2;
#define pp(a,b) push_back(make_pair((a),(b)))
#define pb push_back
#define mp make_pair
#define buybuy {printf("-1\n");return 0;}
#define PI 3.141592653589

int next() {int x; cin >> x; return x;}
lint lnext() {lint x; cin >> x; return x;}
//template<typename T> outln(T x) {cout << x; cout << "\n";}
#define prt(a) cout << a << endl;
#define prtn(a, n) {for(int iiiiiiiiiii = 0; iiiiiiiiiii < n; iiiiiiiiiii++) cout << a[iiiiiiiiiii] << " "; cout << endl;}
#define prtall(a) {for (auto iiiiiiiiiii : a) cout << iiiiiiiiiii << " "; cout << endl;}

int main() {
	cout.precision(20);
	ios_base::sync_with_stdio(false);

	int n = next();
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = next();

	vector<int> down = {200001};
	vector<int> up = {-1};

	vector<bool> is_up(n);

	bool ok = true;

	for (int i = 0; i < n && ok; i++) {
		if (down.back() <= a[i] && up.back() >= a[i]) ok = false;
		else if (down.back() <= a[i]) {
			up.pb(a[i]);
			is_up[i] = true;
		} else if (up.back() >= a[i]) {
			down.pb(a[i]);
			is_up[i] = false;
		} else {
			if (i < n - 1) {
				if (a[i] == a[i + 1]) {
					up.pb(a[i]);

					is_up[i] = true;
				} else if (a[i] > a[i + 1]) {
					down.pb(a[i]);
					is_up[i] = false;
				} else {
					up.pb(a[i]);
					is_up[i] = true;
				}
			} else {
				down.pb(a[i]);
				is_up[i] = false;
			}
		}
	}

	if (ok) {
		cout << "YES\n";
		for (int i = 0; i < n; i++) cout << 1 - is_up[i] << " ";
	} else {
		cout << "NO\n";
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> int2;
#define pp(a,b) push_back(make_pair((a),(b)))
#define pb push_back
#define mp make_pair
#define buybuy {printf("-1\n");return 0;}
#define PI 3.141592653589

int next() {int x; cin >> x; return x;}
lint lnext() {lint x; cin >> x; return x;}
//template<typename T> outln(T x) {cout << x; cout << "\n";}
#define prt(a) cout << a << endl;
#define prtn(a, n) {for(int iiiiiiiiiii = 0; iiiiiiiiiii < n; iiiiiiiiiii++) cout << a[iiiiiiiiiii] << " "; cout << endl;}
#define prtall(a) {for (auto iiiiiiiiiii : a) cout << iiiiiiiiiii << " "; cout << endl;}

int main() {
	cout.precision(20);
	ios_base::sync_with_stdio(false);

	int n = next();
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = next();

	vector<int> down = {200001};
	vector<int> up = {-1};

	vector<bool> is_up(n);

	bool ok = true;

	for (int i = 0; i < n && ok; i++) {
		if (down.back() <= a[i] && up.back() >= a[i]) ok = false;
		else if (down.back() <= a[i]) {
			up.pb(a[i]);
			is_up[i] = true;
		} else if (up.back() >= a[i]) {
			down.pb(a[i]);
			is_up[i] = false;
		} else {
			if (i < n - 1) {
				if (a[i] == a[i + 1]) {
					up.pb(a[i]);
					down.pb(a[i + 1]);

					is_up[i] = true;
					is_up[i + 1] = false;
				} else if (a[i] > a[i + 1]) {
					down.pb(a[i]);
					is_up[i] = false;
				} else {
					up.pb(a[i]);
					is_up[i] = true;
				}
			} else {
				down.pb(a[i]);
				is_up[i] = false;
			}
		}
	}

	if (ok) {
		cout << "YES\n";
		for (int i = 0; i < n; i++) cout << 1 - is_up[i] << " ";
	} else {
		cout << "NO\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
long long int q;
double aarab(double x){
    if (x <= 1){
        return x;
    }
    else {
        x += aarab(x / 10);
        return x;
    }
}

int main (){
    cin >> q;
    double x;
    while(q--){
        cin >> x;
        x = aarab(x);
        cout << (int) x << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
long long int q;
double aarab(double x){
    if (x < 0){
        return x;
    }
    else {
        x += aarab(x / 10);
        return x;
    }
}

int main (){
    cin >> q;
    double x;
    while(q--){
        cin >> x;
        x = aarab(x);
        cout << (int) x << endl;
    }
}


#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define DADAH ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    int t;
    cin>>t;
    while(t--)
    {

    long double n;
    cin>>n;
    lli x=n,tn=10;
    long double sum=0;
    while(n>=10){
        n=n/tn;
        ceil(n);
        sum += n;
    }
    lli sm=x+sum;
    cout<<sm<<endl;

    }

    return 0;

}


#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define DADAH ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
    DADAH

    int t;
    cin>>t;
    while(t--)
    {

    long double n;
    cin>>n;
    lli x=n,tn=10;
    long double sum=0;
    while(n!=0){
        n=n/tn;
        ceil(n);
        sum+=n;
        tn*10;
    }
    //cout<<setprecision(0)<<fixed;
    lli sm=x+sum;
    cout<<sm<<endl;

    }

    return 0;

}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    int ans=0;
    while(n >= 10){
        ans += (n / 10)*10;
        n = n%10+n/10;
    }
    ans+=n;
    cout<<ans<<'\n';
    return 0;}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;cin>>t;
    for(int i=0;i<t;++i){
        int n;
        cin>>n;
        int ans=0;
        while(n >= 10){
            ans += (n / 10)*10;
            n = n%10+n/10;
        }
        ans+=n;
        cout<<ans<<'\n';
    }return 0;

}


#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define DADAH ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        lli x=n, tn=10;
        long long sum=0;
        while(n>=10){
            n=n/tn;
            n=ceil(n);
            sum += n;
        }
        lli sm=x+sum;
        cout<<sm<<endl;
    }

    return 0;

}


#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define DADAH ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    int t;
    cin>>t;
    while(t--)
    {

    long long n;
    cin>>n;
    lli x=n,tn=10;
    long long sum=0;
    while(n>=10){
        n=n/tn;
        ceil(n);
        sum += n;
    }
    lli sm=x+sum;
    cout<<sm<<endl;

    }

    return 0;

}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

///https://www.geeksforgeeks.org/ordered-set-gnu-c-pbds/

#define pb              push_back
#define ll              long long
#define str             string
#define fi              first
#define se              second
#define ln              cout<<'\n'
#define R               cin>>
#define for0(i, n)      for (ll i = 0; i < n; ++i)
#define for1(i, n)      for (ll i = 1; i <= n;++i)
#define for2(i, n)      for (ll i = 1; i < n; ++i)
#define for3(i, k, n)   for (ll i = k; i < n; ++i)
#define all(c)          (c).begin(),(c).end()

#define fori(itt, stt)  for(itt = stt.begin(); itt != stt.end(); ++itt)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define ld              long double
//КТУ(A,B)=__gcd(A,B);

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    int n;
    cin>>n;
    int ans=0;
    while(n >= 10){
        ans += (n / 10)*10;
        n = n%10+n/10;
    }
    if(n<10)ans+=n;
    cout<<ans<<'\n';
}

int main() {
    /*ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);*/
    ll t=1;
    cin>>t;
    for1(www,t) solve();
    return 0;}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,c,d, e,f,g,h,i,j;
    cin>>a;
    for(ll i =0;i<a;i++)
    {
        cin>>b;
    }
    cout<<1<<endl<<11<<endl<<21<<endl<<10973<<endl<<13716<<endl<<1111111111;
}