#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     vector<long long> a;     vector<int> pos;     for (int i = n; i > 0; i--) {       long long p;       cin >> p;       if (p == 0) continue;       a.push_back(p);       pos.push_back(i);     }     reverse(a.begin(), a.end());     reverse(pos.begin(), pos.end());     if (a.empty()) {       cout << string(n,  0 );       return 0;     }     int sz = a.size();     vector<int> last_id(sz);     for (int i = sz - 1; i >= 0; i--) {       if (i < sz - 1 && a[i] == a[i + 1])         last_id[i] = last_id[i + 1];       else         last_id[i] = i;     }     auto get_sum = [&](int l, int r) {       return 1LL * r * (r + 1) / 2 - 1LL * (l - 1) * l / 2;     };     auto solve = [&](long long sum, int l, int r) {       vector<pair<int, int>> res;       if (sum == 0) return res;       if (l > r) {         res = {{-1, -1}};         return res;       }       if (sum < 0 || sum > get_sum(l, r)) {         res = {{-1, -1}};         return res;       }       if (sum == get_sum(l, r)) {         res.emplace_back(l, r);         return res;       }       int lo = 0, hi = r - l + 1;       while (hi - lo > 1) {         int mid = (hi + lo) >> 1;         if (sum >= get_sum(l, l + mid - 1))           lo = mid;         else           hi = mid;       }       int st = lo;       if (sum > get_sum(r - st + 1, r)) {         res = {{-1, -1}};         return res;       }       int skip = r - (l + st - 1);       long long add = sum - get_sum(l, l + st - 1);       int cnt = add / skip;       pair<int, int> a = {l, l + st - 1 - cnt};       pair<int, int> b = {r - cnt + 1, r};       if (add > skip * cnt) {         int c = a.second;         a.second--;         c += add - 1LL * skip * cnt;         res.push_back({c, c});       }       if (a.first <= a.second) res.push_back(a);       if (b.first <= b.second) res.push_back(b);       return res;     };     auto check = [&](vector<pair<int, int>> foo) {       return !(foo.size() == 1 && foo[0] == make_pair(-1, -1));     };     vector<long long> supose(n + 1);     for (int i = n; i > 0; i--) {       int p = lower_bound(pos.begin(), pos.end(), i) - pos.begin();       if (pos[p] == i)         supose[i] = a[p];       else         supose[i] = a[p] - 1;     }     vector<bool> dp(n + 1);     vector<int> par(n + 1);     vector<vector<pair<int, int>>> aux_seg(n + 1);     vector<int> last_true(sz);     int go_from = pos.back();     auto add = [&](int from, int to, int l, int r) {       long long sum = supose[from] - from;       if (to <= n) sum -= supose[to];       auto foo = solve(sum, l, r);       if (check(foo)) {         dp[from] = true;         par[from] = to;         aux_seg[from] = foo;       }     };     for (int cur = go_from; cur > 0; cur--) {       int p = lower_bound(pos.begin(), pos.end(), cur) - pos.begin();       if (pos[p] == cur && p < sz - 1) {         if (a[p] == a[p + 1]) continue;         if (a[p] == a[p + 1] - 1) {           int np = last_id[p + 1];           if (np == sz - 1 || dp[pos[np + 1]]) {             int l = pos[np] + 1;             int r = np == sz - 1 ? n : pos[np + 1] - 1;             add(cur, r + 1, l, r);           }           if (last_true[np]) {             int l = pos[np] + 1;             int r = last_true[np] - 1;             add(cur, r + 1, l, r);           }         }       }       int np = last_id[p];       if (np == sz - 1 || dp[pos[np + 1]]) {         int l = pos[np] + 1;         int r = np == sz - 1 ? n : pos[np + 1] - 1;         add(cur, r + 1, l, r);       }       if (last_true[np]) {         int l = pos[np] + 1;         int r = last_true[np] - 1;         add(cur, r + 1, l, r);       }       if (pos[p] != cur && p && !last_true[p - 1] && dp[cur]) {         last_true[p - 1] = cur;       }     }     string res(n + 1,  0 );     long long bound = -1;     for (int i = 1; i <= n; i++) {       if (dp[i] && (bound == -1 || supose[i] == bound - 1)) {         while (i <= n) {           res[i] =  1 ;           for (auto foo : aux_seg[i]) {             for (int j = foo.first; j <= foo.second; j++) res[j] =  1 ;           }           i = par[i];         }         break;       }       if (pos[0] == i) {         bound = a[0];       }     }     res.erase(res.begin());     reverse(res.begin(), res.end());     cout << res;     return 0;   }