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.
import java.io.*;
import java.math.*;
import java.util.*;

public class OmkarAndWaterslides {
	static PrintWriter pw;

	static class FastReader {
		private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar, numChars;

		public FastReader() {
			this(System.in);
		}

		public FastReader(InputStream is) {
			mIs = is;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = mIs.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long l() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int i() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double d() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public void scanIntArr(int[] arr) {
			for (int li = 0; li < arr.length; ++li)
				arr[li] = i();
		}

		public void scanIntIndexArr(int[] arr) {
			for (int li = 0; li < arr.length; ++li) {
				arr[li] = i() - 1;
			}
		}

		public void printIntArr(int[] arr) {
			for (int li = 0; li < arr.length; ++li)
				pw.print(arr[li] + " ");
			pw.println();
		}

		public void printLongArr(long[] arr) {
			for (int li = 0; li < arr.length; ++li)
				pw.print(arr[li] + " ");
			pw.println();
		}

		public void scanLongArr(long[] arr) {
			for (int i = 0; i < arr.length; ++i) {
				arr[i] = l();
			}
		}

		public void shuffle(int[] arr) {
			for (int i = arr.length; i > 0; --i) {
				int r = (int) (Math.random() * i);
				int temp = arr[i - 1];
				arr[i - 1] = arr[r];
				arr[r] = temp;
			}
		}

		public int findMax(int[] arr) {
			return Arrays.stream(arr).max().getAsInt();
		}
	}

	public static void main(String[] args) throws IOException {
		FastReader fr = new FastReader();
		pw = new PrintWriter(System.out);
		int i, j, n, t;
		long temp, mn;
		t = fr.i();
		long prev = 0, curr;
		long a[];
		while (t-- > 0) {
			temp = 0;
			n = fr.i();
			a = new long[n];
			fr.scanLongArr(a);
			for (i = 1; i < n; i++) {
				temp += Math.max(a[i - 1] - a[i], 0);
			}

			pw.println(temp);
		}
		pw.flush();
		pw.close();
	}
}