#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int h[n];     for (int i = 0; i < n; i++) cin >> h[i];     int max;     int a[n];     a[n - 1] = 0;     max = h[n - 1];     for (int i = n - 2; i >= 0; i--) {       if (h[i] > max) {         a[i] = 0;         max = h[i];       } else {         a[i] = max - h[i] + 1;       }     }     for (int i = 0; i < n; i++) {       printf( %d  , a[i]);     }     printf(  n );     return 0;   }   