description: Shohag has an integer sequence a_1, a_2, …, a_n. He can perform the following operation any number of times (possibly, zero):
  
    * Select any positive integer k (it can be different in different operations). 
    * Choose any position in the sequence (possibly the beginning or end of the sequence, or in between any two elements) and insert k into the sequence at this position. 
    * This way, the sequence a changes, and the next operation is performed on this changed sequence. 
  
  
  
  For example, if a=[3,3,4] and he selects k = 2, then after the operation he can obtain one of the sequences [\underline{2},3,3,4], [3,\underline{2},3,4], [3,3,\underline{2},4], or [3,3,4,\underline{2}].
  
  Shohag wants this sequence to satisfy the following condition: for each 1 ≤ i ≤ |a|, a_i ≤ i. Here, |a| denotes the size of a.
  
  Help him to find the minimum number of operations that he has to perform to achieve this goal. We can show that under the constraints of the problem it's always possible to achieve this goal in a finite number of operations.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.
  
  The first line of each test case contains a single integer n (1 ≤ n ≤ 100) — the initial length of the sequence.
  
  The second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the elements of the sequence.
  
  Output
  
  For each test case, print a single integer — the minimum number of operations needed to perform to achieve the goal mentioned in the statement.
  
  Example
  
  Input
  
  
  4
  3
  1 3 4
  5
  1 2 5 7 4
  1
  1
  3
  69 6969 696969
  
  
  Output
  
  
  1
  3
  0
  696966
  
  Note
  
  In the first test case, we have to perform at least one operation, as a_2=3>2. We can perform the operation [1, 3, 4] → [1, \underline{2}, 3, 4] (the newly inserted element is underlined), now the condition is satisfied.
  
  In the second test case, Shohag can perform the following operations:
  
  [1, 2, 5, 7, 4] → [1, 2, \underline{3}, 5, 7, 4] → [1, 2, 3, \underline{4}, 5, 7, 4] → [1, 2, 3, 4, 5, \underline{3}, 7, 4].
  
  In the third test case, the sequence already satisfies the condition.
solution: 
  import java.util.*;
  import java.lang.*;
  import java.io.*;
  import java.math.BigInteger;
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.math.BigInteger;
  import java.util.List;
  import java.util.Map;
  import java.util.Map.Entry;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.Comparator;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  public class codeee
  {		//public static int mod=1000000007;
  	public static ArrayList<Integer> Factors(int n)
      {
  		ArrayList<Integer> arr=new ArrayList<Integer>();
          int k=0;
          while (n%2==0)
          {
              k++;
              n /=2;
              arr.add(2);
          }
  	int p=(int) Math.sqrt(n); 
          for (int i = 3; i <=p; i+= 2)
          
          {  if(n==1)break;
              while (n%i == 0)
              {
                  k++;
                  arr.add(i);
                  n /= i;
              }
          }
          if (n > 2)
          {
          	arr.add(n);
          }
             
   //arr.add(1);
     return arr;
      } 
  	static class Reader {
  		 
  	        final private int BUFFER_SIZE = 1 << 16;
  	        private DataInputStream din;
  	        private byte[] buffer;
  	        private int bufferPointer, bytesRead;
  	 
  	        public Reader()
  	        {
  	            din = new DataInputStream(System.in);
  	            buffer = new byte[BUFFER_SIZE];
  	            bufferPointer = bytesRead = 0;
  	        }
  	 
  	        public Reader(String file_name) throws IOException
  	        {
  	            din = new DataInputStream(
  	                new FileInputStream(file_name));
  	            buffer = new byte[BUFFER_SIZE];
  	            bufferPointer = bytesRead = 0;
  	        }
  	 
  	        public String readLine() throws IOException
  	        {
  	            byte[] buf = new byte[64]; // line length
  	            int cnt = 0, c;
  	            while ((c = read()) != -1) {
  	                if (c == '\n') {
  	                    if (cnt != 0) {
  	                        break;
  	                    }
  	                    else {
  	                        continue;
  	                    }
  	                }
  	                buf[cnt++] = (byte)c;
  	            }
  	            return new String(buf, 0, cnt);
  	        }
  	 
  	        public int nextInt() throws IOException
  	        {
  	            int ret = 0;
  	            byte c = read();
  	            while (c <= ' ') {
  	                c = read();
  	            }
  	            boolean neg = (c == '-');
  	            if (neg)
  	                c = read();
  	            do {
  	                ret = ret * 10 + c - '0';
  	            } while ((c = read()) >= '0' && c <= '9');
  	 
  	            if (neg)
  	                return -ret;
  	            return ret;
  	        }
  	 
  	        public long nextLong() throws IOException
  	        {
  	            long ret = 0;
  	            byte c = read();
  	            while (c <= ' ')
  	                c = read();
  	            boolean neg = (c == '-');
  	            if (neg)
  	                c = read();
  	            do {
  	                ret = ret * 10 + c - '0';
  	            } while ((c = read()) >= '0' && c <= '9');
  	            if (neg)
  	                return -ret;
  	            return ret;
  	        }
  	 
  	        public double nextDouble() throws IOException
  	        {
  	            double ret = 0, div = 1;
  	            byte c = read();
  	            while (c <= ' ')
  	                c = read();
  	            boolean neg = (c == '-');
  	            if (neg)
  	                c = read();
  	 
  	            do {
  	                ret = ret * 10 + c - '0';
  	            } while ((c = read()) >= '0' && c <= '9');
  	 
  	            if (c == '.') {
  	                while ((c = read()) >= '0' && c <= '9') {
  	                    ret += (c - '0') / (div *= 10);
  	                }
  	            }
  	 
  	            if (neg)
  	                return -ret;
  	            return ret;
  	        }
  	 
  	        private void fillBuffer() throws IOException
  	        {
  	            bytesRead = din.read(buffer, bufferPointer = 0,
  	                                 BUFFER_SIZE);
  	            if (bytesRead == -1)
  	                buffer[0] = -1;
  	        }
  	 
  	        private byte read() throws IOException
  	        {
  	            if (bufferPointer == bytesRead)
  	                fillBuffer();
  	            return buffer[bufferPointer++];
  	        }
  	 
  	        public void close() throws IOException
  	        {
  	            if (din == null)
  	                return;
  	            din.close();
  	        }
  	 }
  	 public static long gcd(long x, long p)
  	    {
  	        if (x == 0)
  	            return p;
  	         
  	        return gcd(p%x, x);
  	    }
  	 public static HashMap<Integer, Integer> sortByValue(HashMap<Integer, Integer> hm)
  	    {
  	        // Create a list from elements of HashMap
  	        List<Map.Entry<Integer, Integer> > list =
  	               new LinkedList<Map.Entry<Integer, Integer> >(hm.entrySet());
  	 
  	        // Sort the list
  	        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer> >() {
  	            public int compare(Map.Entry<Integer, Integer> o1,
  	                               Map.Entry<Integer, Integer> o2)
  	            {
  	                return (o1.getValue()).compareTo(o2.getValue());
  	            }
  	        });
  	         
  	        // put data from sorted list to hashmap
  	        HashMap<Integer, Integer> temp = new LinkedHashMap<Integer, Integer>();
  	        for (Map.Entry<Integer, Integer> aa : list) {
  	            temp.put(aa.getKey(), aa.getValue());
  	        }
  	        return temp;
  	    }
  	 static int sieve =  1000000 ;
  
  
  	 static boolean[] prime =  new boolean[sieve + 1] ;
  
  	 public static void sieveOfEratosthenes() 
  	     { 
  	         // FALSE == prime and 1 // TRUE ==  COMPOSITE
  	         
  	         // time complexity = 0(NlogLogN)== o(N)
  	         
  	         // gives prime nos bw 1 to N // size - 1e7(at max)
  	         
  	         for(int i = 4; i<= sieve ; i++)
  	         {
  	             prime[i] = true  ; i++ ;
  	            
  	         }
  	         
  	         for(int p = 3; p*p <= sieve; p++) 
  	         { 
  	            if(prime[p] == false) 
  	             { 
  	                     for(int i = p*p; i <= sieve; i += p) 
  	                     prime[i] = true; 
  	             } 
  	             
  	             p++ ;
  	         } 
  	           
  	     } 
  	 public static void arrInpInt(int [] arr, int n) throws IOException
  	 {
  		 Reader reader = new Reader();
  		 for(int i=0;i<n;i++)
  	   		{
  	   			arr[i]=reader.nextInt();	
  	   		}
  	 }
  	 public static void arrInpLong(long [] arr, int n) throws IOException
  	 {
  		 Reader reader = new Reader();
  		 for(int i=0;i<n;i++)
  	   		{
  	   			arr[i]=reader.nextLong();	
  	   		}
  	 }
  	 public static void printArr(int[] arr)
  	 {
  		 for(int i=0;i<arr.length;i++)
  		 {
  			 System.out.print(arr[i]+" ");
  		 }
  		 System.out.println();
  	 }
  	 public static int[] decSort(int[] arr)
  	 {
  		  int[] arr1 = Arrays.stream(arr).boxed().sorted(Collections.reverseOrder()).mapToInt(Integer::intValue).toArray();	
  		  return arr1;
  	 }
  	 
  	
  	//if present - return the first occurrence of the no
  	//not present- return the index of next greater value 
  	//if greater than all the values return N(taking high=N-1)
  	//if smaller than all the values return 0(taking low =0)
  	static int lower_bound(int arr[], int low,int high, int X)
  	{
  
  	 if (low > high) {
  	     return low;
  	 }
  	 int mid = low + (high - low) / 2;
  	 if (arr[mid] >= X) {
  	     return lower_bound(arr, low,
  	                        mid - 1, X);
  	 }
  
  	 return lower_bound(arr, mid + 1,
  	                    high, X);
  	}
  	//if present - return the index of next greater value
  	//not present- return the index of next greater value 
  	//if greater than all the values return N(taking high=N-1)
  	//if smaller than all the values return 0(taking low =0)\
  	
  	static int upper_bound(int arr[], int low, int high, int X)
  {
  
  if (low > high)
      return low;
  
  int mid = low + (high - low) / 2;
  if (arr[mid] <= X) {
      return upper_bound(arr, mid + 1,
                         high, X);
  }
  
  return upper_bound(arr, low,
                     mid - 1, X);
  }
  	
  	
  	 public static class Pair  {// comparator with class
  		    int x;
  		    int y;
  		 public Pair(int x, int y)
  		    {
  		        this.x = x;
  		        this.y = y;
  		    }
  		}
  	
  	 public static void sortbyColumn(int arr[][], int col)  // send 2d array and col no
  	    {
  	        Arrays.sort(arr, new Comparator<int[]>() {       
  	          @Override              
  	          public int compare(final int[] entry1, 
  	                             final int[] entry2) {
  	            if (entry1[col] > entry2[col])
  	                return 1;
  	            else if (entry1[col] < entry2[col])
  	                return -1;
  	              else return 0;
  	          }
  	        });
  	    }
  	 public static void sortbyColumn1(int arr[][], int col)  // send 2d array and col no
  	    {
  	        Arrays.sort(arr, new Comparator<int[]>() {       
  	          @Override              
  	          public int compare(final int[] entry1, 
  	                             final int[] entry2) {
  	            if (entry1[col] > entry2[col])
  	                return 1;
  	            else if (entry1[col] < entry2[col])
  	                return -1;
  	            else if(entry1[col] == entry2[col])
  	            {
  	            	if(entry1[col-1]>entry2[col-1])
  	            		return -1;
  	            	else if(entry1[col-1]<entry2[col-1])
  	            		return 1;
  	            	else return 0;
  	            }
  	              else return 0;
  	          }
  	        });
  	    }
  	 public static void print2D(int mat[][])
  	    {
  	        // Loop through all rows
  	        for (int i = 0; i < mat.length; i++)
  	 
  	        {  // Loop through all elements of current row
  	        {
  	            for (int j = 0; j < mat[i].length; j++)
  	                System.out.print(mat[i][j] + " ");
  	        }
  	            System.out.println();
  	        }
  	    }
  	 public static int biggestFactor(int num) {
  		  int  result = 1;
  		  for(int  i=2; i*i <=num; i++){
  		      if(num%i==0){
  		          result = num/i;
  		          break;
  		      }
  		  }
  		  return result;
  		}
  	    public static class  p
  	     {
  	    	 int no;
  	    	 int h;
  	    	 public p(int no, long h)
  	    	 {
  	    		 this.no=no;
  	    		 this.h=(int) h;
  	    	 }
  	     }
  	    public static class  k
  	     {
  	    	 boolean inc;
  	    	 int min;
  	    	 int max;
  	    	 public k(boolean inc,int min, int max)
  	    	 {
  	    		 this.inc=inc;
  	    		 this.min=min;
  	    		 this.max=max;
  	    	 }
  	     }
  	    
  	  static    class com implements Comparator<p>{
  	            public int compare(p s1, p s2) {
  	                if (s1.h > s2.h)
  	                    return -1;
  	                else if (s1.h < s2.h)
  	                    return 1;
  	                else if(s1.h==s2.h)
  	                {
  	                	if(s1.no>s2.no)return -1;
  	                	else return 1;
  	                }
  	                                return 0;
  	                }
  	        }
  	  static long hcf(long a,long b)
  	  {
  	    while (b > 0)
  	    {
  	        long temp = b;
  	        b = a % b; 
  	        a = temp;
  	    }
  	    return a;
  	   }
  	  public static int max=Integer.MIN_VALUE;
  	  public static HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
  	  public static int rec(int[] arr,int ind)
  	  {
  		  if(ind>arr.length)return 0;
  		  if(map.containsKey(ind))return map.get(ind);
  		  int count=0;
  		  for(int i=2*ind ;i<=arr.length;i=i+ind)
  		  {
  			  if(arr[i-1]>arr[ind-1])
  			  {
  				  count=Math.max(count, 1+rec(arr,i));
  			  }
  		  }
  		  map.put(ind, count);
  		  //System.out.println(count);
  		  max=Math.max(max, count);
  		  return count;
  	  }
  	 
   	public static void main(String args[]) throws NumberFormatException, IOException ,java.lang.Exception
  	{
  		
  		Reader reader = new Reader();
  		//sieveOfEratosthenes();
  		//System.out.println(prime[0]+" "+prime[1]+" "+prime[2]+" "+prime[3]+" "+prime[4]);
  		//Scanner reader=new Scanner(System.in);
  		
  		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		//int cases=Integer.parseInt(br.readLine());
  		//int cases=1;
  		//BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
  		int cases=reader.nextInt();
  		
     	while (cases-->0){
     		//long V=reader.nextLong();
     		//long C=reader.nextLong();
     	//	long N=reader.nextLong();
  //   		long M=reader.nextLong();
     		
     		int N=reader.nextInt();
     	//	int K=reader.nextInt();
     		//BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
    // 		int P=reader.nextInt();
     		//int[][] arr=new int[N][N];
     //	int K=reader.nextInt();
     		//int X=reader.nextInt();
     		//int K=reader.nextInt();
     		//int S=reader.nextInt();
     		//int circum=reader.nextInt();
     		//int K=reader.nextInt();
     		//String[] first=br.readLine().split(" ");
     		//int N=Integer.parseInt(first[0]);
     		//char p=first[1].charAt(0);
     		//int P=Integer.parseInt(first[1]);
     		//int K=Integer.parseInt(first[2]);
     		//String[] first=br.readLine().split(" ");
     		//int N=Integer.parseInt(first[0]);
     		//int K=Integer.parseInt(first[1]);
     		//int X=reader.nextInt();
     		//int Y=reader.nextInt();
     		//String s2=br.readLine();
     		//String s3=br.readLine();
     		//char[]  s11=s2.toCharArray();
     		//char[]  s12=s3.toCharArray();
     		
     		//String[] first1=br.readLine().split(" ");
     		//int C=Integer.parseInt(first1[0]);
     		//int C1=Integer.parseInt(first1[1]);
     		//char[]  s12=s3.toCharArray();
      	//int max=Integer.MIN_VALUE;
     		//int min=Integer.MAX_VALUE;
     		//int ind=-1;
     		//HashMap<Integer,Integer> a1=new HashMap<Integer,Integer>();
     		//HashMap<Long,Long> b1=new HashMap<Long,Long>();
     		//HashMap<String,String> path=new HashMap<String,String>();
     		//TreeMap<Integer,Integer> map=new TreeMap<Integer,Integer>(Collections.reverseOrder());
     		//HashSet<String> sum =new HashSet<String>(); 
     		//TreeSet<Integer> a =new TreeSet<Integer>();
     		//TreeSet<Long> b =new TreeSet<Long>();
     		//TreeSet<Integer> map=new TreeSet<Integer>();
     		int[] arr=new int[N];
     		//int[] arr1=new int[K];
     		//Integer[] arr2=new Integer[N];
     		//boolean[]arr1=new boolean[N];
     		//int[] arr=new int[N];
  
     		//ArrayList<Integer> k=new ArrayList<Integer>();
     		//ArrayList<Integer> k1=new ArrayList<Integer>();
     		//int [][] arr=new int[N][5];
          //System.out.println(map);
     		//PriorityQueue<p> Q=new PriorityQueue<p>(new com());
     		//PriorityQueue<Long> w=new PriorityQueue<Long>();
     		
     		//int min=Integer.MAX_VALUE;
     		
     		//ArrayList<ArrayList<Integer>> arr=new ArrayList<ArrayList<Ineteger>>();
     		//System.out.println();
     		
     		//System.out.println(zero+" "+one);
     	
     		for(int i=0;i<N;i++)arr[i]=reader.nextInt();
     		long ans=0;
     		long ind=1;
     		for(int i=0;i<N;i++ )
     		{
     			if(arr[i]>ind)
     			{
     				ans=ans+arr[i]-ind;
     				ind=arr[i]+1;
     			}
     			else ind++;
     		}
     		System.out.println(ans);
     		
     		
  		
     	}
     		
     	
  }
  }
   	
          //System.out.println(Arrays.toString(sum));    
   	
     	
  