func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MX = (int)1e6 + 17;   const int MOD = (int)1e9 + 7;   const long long oo = (long long)1e18 + 7;   const int INF = (int)999999999;   const int N = (int)1e5 + 17;   const int di[4] = {-1, 0, 1, 0};   const int dj[4] = {0, 1, 0, -1};   inline long long IN() {     long long x = 0, ch = getchar(), f = 1;     while (!isdigit(ch) && (ch !=  - ) && (ch != EOF)) ch = getchar();     if (ch ==  - ) {       f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void OUT(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10)       OUT(x / 10), putchar(x % 10 +  0 );     else       putchar(x +  0 );   }   int n, mx;   int a[N], t[N * 4];   void build(int v, int tl, int tr) {     if (tl == tr)       t[v] = a[tl];     else {       int tm = (tl + tr) / 2;       build(v * 2, tl, tm);       build(v * 2 + 1, tm + 1, tr);       t[v] = max(t[v * 2], t[v * 2 + 1]);     }   }   int get(int l, int r, int v, int tl, int tr) {     if (l <= tl && tr <= r) return t[v];     if (tr < l || tl > r) return 0;     int tm = (tl + tr) / 2;     return max(get(l, r, v * 2, tl, tm), get(l, r, v * 2 + 1, tm + 1, tr));   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     build(1, 1, n);     for (int i = 1; i <= n; i++) {       if (i < n) {         int x = get(i + 1, n, 1, 1, n);         if (x < a[i])           cout << 0 <<    ;         else           cout << x - a[i] + 1 <<    ;       } else         cout << 0 <<    ;     }     return 0;   }   