Time Limit:3000ms Memory Limit:65536KB
Given a sequence, you can transform it into a nondecreasing sequence by performing the following
operation zero or more times: select any term in the sequence and either increase it or decrease
it by one. You are allowed to perform any number of these operations on any of the terms. Given a
sequence of numbers A1, A2,  , An, you are to calculate the minimum number of
operations required to transform the given sequence into a nondecreasing sequence.
The first line of the input is an integer T which indicates the number of test cases.
  For each test case, the first line contains an integer N (1  N  1,000), the length of the
  Second line contains N numbers describing the sequence. Every integer in the sequence is between
  0 and 1,000,000 inclusively.

  For each test case, print a line contains the minimum number of operations.
Sample Input
3 2 1 4
Sample Output