Omkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible.

Omkar currently has n supports arranged in a line, the i-th of which has height a_i. Omkar wants to build his waterslide from the right to the left, so his supports must be nondecreasing in height in order to support the waterslide. In 1 operation, Omkar can do the following: take any contiguous subsegment of supports which is nondecreasing by heights and add 1 to each of their heights. 

Help Omkar find the minimum number of operations he needs to perform to make his supports able to support his waterslide!

An array b is a subsegment of an array c if b can be obtained from c by deletion of several (possibly zero or all) elements from the beginning and several (possibly zero or all) elements from the end.

An array b_1, b_2, ..., b_n is called nondecreasing if b_i≤ b_{i+1} for every i from 1 to n-1.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.

The first line of each test case contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of supports Omkar has.

The second line of each test case contains n integers a_{1},a_{2},...,a_{n} (0 ≤ a_{i} ≤ 10^9) — the heights of the supports.

It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case, output a single integer — the minimum number of operations Omkar needs to perform to make his supports able to support his waterslide.

Example

Input


3
4
5 3 2 5
5
1 2 3 5 3
3
1 1 1


Output


3
2
0

Note

The subarray with which Omkar performs the operation is bolded.

In the first test case:

  * First operation:

[5, 3, 2, 5] → [5, 3, 3, 5]

  * Second operation:

[5, 3, 3, 5] → [5, 4, 4, 5]

  * Third operation:

[5, 4, 4, 5] → [5, 5, 5, 5]




In the third test case, the array is already nondecreasing, so Omkar does 0 operations.
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
long long int nCrModPFermat(long long int n, long long int r, long long int p) {
  if (r == 0) return 1;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
vector<long long int> lps(string s) {
  long long int n = (long long int)s.length();
  vector<long long int> pi(n);
  for (long long int i = 1; i < n; i++) {
    long long int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) j++;
    pi[i] = j;
  }
  return pi;
}
vector<long long int> kmp(string s, string t) {
  vector<long long int> v1 = lps(s + '#' + t);
  vector<long long int> v2;
  for (long long int i = 0; i < (long long int)v1.size(); i++) {
    if (v1[i] == (long long int)s.size()) {
      v2.push_back(i - 2 * s.size());
    }
  }
  return v2;
}
long long int ALPHABET_SIZE = 26;
struct TrieNode {
  struct TrieNode *children[26];
  bool isEndOfWord;
};
struct TrieNode *getNode(void) {
  struct TrieNode *pNode = new TrieNode;
  pNode->isEndOfWord = false;
  for (int i = 0; i < ALPHABET_SIZE; i++) pNode->children[i] = NULL;
  return pNode;
}
void insert(struct TrieNode *root, string key) {
  struct TrieNode *pCrawl = root;
  for (int i = 0; i < key.length(); i++) {
    int index = key[i] - 'a';
    if (!pCrawl->children[index]) pCrawl->children[index] = getNode();
    pCrawl = pCrawl->children[index];
  }
  pCrawl->isEndOfWord = true;
}
bool search(struct TrieNode *root, string key) {
  struct TrieNode *pCrawl = root;
  for (long long int i = 0; i < key.length(); i++) {
    int index = key[i] - 'a';
    if (!pCrawl->children[index]) return false;
    pCrawl = pCrawl->children[index];
  }
  return (pCrawl != NULL && pCrawl->isEndOfWord);
}
long long int lcs(string A, string B) {
  const int x = A.size(), y = B.size();
  long long int dp[x + 1][y + 1];
  for (int i = 0; i < x + 1; i++) dp[i][0] = 0;
  for (int i = 0; i <= y; i++) dp[0][i] = 0;
  for (int i = 1; i <= x; i++) {
    for (int j = 1; j <= y; j++) {
      if (A[i - 1] == B[j - 1])
        dp[i][j] = max(dp[i - 1][j - 1] + 1, max(dp[i - 1][j], dp[i][j - 1]));
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  return dp[x][y];
}
long long int findSubarraySum(long long int arr[], long long int n,
                              long long int sum) {
  unordered_map<long long int, long long int> prevSum;
  long long int res = 0;
  long long int currsum = 0;
  for (int i = 0; i < n; i++) {
    currsum += arr[i];
    if (currsum == sum) res++;
    if (prevSum.find(currsum - sum) != prevSum.end())
      res += (prevSum[currsum - sum]);
    prevSum[currsum]++;
  }
  return res;
}
long long int maxSubArraySum(vector<long long int> &a, long long int size) {
  long long int max_so_far = INT_MIN, max_ending_here = 0;
  for (int i = 0; i < size; i++) {
    max_ending_here = max_ending_here + a[i];
    if (max_so_far < max_ending_here) max_so_far = max_ending_here;
    if (max_ending_here < 0) max_ending_here = 0;
  }
  return max_so_far;
}
long long int dfs(long long int u, vector<vector<long long int> > &v,
                  vector<long long int> &tr, vector<long long int> &p) {
  for (long long int i = 0; i < (long long int)v[u].size(); i++) {
    if (v[v[u][i]].size() == 1) {
      tr[v[u][i]] = p[v[u][i]];
      return p[v[u][i]];
    } else {
      tr[v[u][i]] = p[v[u][i]] + dfs(v[u][i], v, tr, p);
      return p[v[u][i]];
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> v;
    for (long long int i = 0; i < n; i++) {
      long long int a;
      cin >> a;
      v.push_back(a);
    }
    long long int ans = 0, mx = 0, temp = 0;
    for (long long int i = 1; i < v.size(); i++) {
      if (v[i] - v[i - 1] < 0) ans = ans + (v[i - 1] - v[i]);
    }
    cout << ans << "\n";
  }
  return 0;
}
