func_code_string: #include <bits/stdc++.h>   using namespace std;   const int LEN = 100000;   struct fastio {     int it, len;     char s[LEN + 5];     fastio() { it = len = 0; }     char get() {       if (it < len) return s[it++];       it = 0, len = fread(s, 1, LEN, stdin);       return len ? s[it++] : EOF;     }     bool notend() {       char c;       for (c = get(); c ==     || c ==   n  || c ==   r ; c = get())         ;       if (it) it--;       return c != EOF;     }     void put(char c) {       if (it == LEN) fwrite(s, 1, LEN, stdout), it = 0;       s[it++] = c;     }     void flush() { fwrite(s, 1, it, stdout); }   } buff, bufo;   inline int getint() {     char c;     int res = 0, sig = 1;     for (c = buff.get(); c <  0  || c >  9 ; c = buff.get())       if (c ==  - ) sig = -1;     for (; c >=  0  && c <=  9 ; c = buff.get()) res = res * 10 + (c -  0 );     return sig * res;   }   inline long long getll() {     char c;     long long res = 0, sig = 1;     for (c = buff.get(); c <  0  || c >  9 ; c = buff.get())       if (c ==  - ) sig = -1;     for (; c >=  0  && c <=  9 ; c = buff.get()) res = res * 10 + (c -  0 );     return sig * res;   }   inline void putint(int x, char suf) {     if (!x)       bufo.put( 0 );     else {       if (x < 0) bufo.put( - ), x = -x;       int k = 0;       char s[15];       while (x) {         s[++k] = x % 10 +  0 ;         x /= 10;       }       for (; k; k--) bufo.put(s[k]);     }     bufo.put(suf);   }   inline void putll(long long x, char suf) {     if (!x)       bufo.put( 0 );     else {       if (x < 0) bufo.put( - ), x = -x;       int k = 0;       char s[25];       while (x) {         s[++k] = x % 10 +  0 ;         x /= 10;       }       for (; k; k--) bufo.put(s[k]);     }     bufo.put(suf);   }   inline char get_char() {     char c;     for (c = buff.get(); c ==     || c ==   n  || c ==   r ; c = buff.get())       ;     return c;   }   int a[200005];   void solve() {     int n = getint();     for (int i = 1; i <= n; i++) a[i] = getint();     long long ans = 0;     for (int i = 1; i < n; i++)       if (a[i] > a[i + 1]) ans += a[i] - a[i + 1];     putll(ans,   n );   }   int main() {     int T = getint();     while (T--) solve();     bufo.flush();     return 0;   }   