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:  //package eround101;
  
  import java.util.*;
  import java.io.*;
  import java.lang.*;
  import java.util.StringTokenizer;
  
  public class Solution {
  
      static HritikScanner sc = new HritikScanner();
      static PrintWriter pw = new PrintWriter(System.out, true);
      final static int MOD = 1000000007;
      static StringBuilder sb = new StringBuilder();
  
      public static void main(String[] args) {
  
          int t = ni();
          while (t-- > 0) {
              solve();
          }
      }
  
      static void solve() {
          int n = ni();
          long[] arr = nextLongArray(n);
          long[] ind = new long[n];
          long ans = 0;
          ind[0] = 1;
          if(arr[0] > 1)
          {
              ind[0] = arr[0];
              ans += arr[0]-1;
          }
          for(int i = 1; i < n; i++)
          {
              if(arr[i] > ind[i-1]+1)
              {
                  ans += arr[i]-(ind[i-1]+1);
                  ind[i] = arr[i];
              }
              else
              {
                  ind[i] = ind[i-1]+1;
              }
              
          }
          pl(ans);
      }
          /////////////////////////////////////////////////////////////////////////////////
      static class FenwickTree { // Binary Index Tree
          int[] tree;
          static int size;
  
          public FenwickTree(int size) {
              this.size = size;
              tree = new int[size + 5];
          }
  
          public void add(int i, int val) {
              while (i <= size) {
                  tree[i] += val;
                  i += i & -i;  // adding the decimal value of the last set bit.
              }
          }
  
          public int sum(int i) {
              int res = 0;
              while (i >= 1) {
                  res += tree[i];
                  i -= i & -i; // deleting the last set bit
              }
              return res;
          }
  
          public int sum(int l, int r) {
              return sum(r) - sum(l - 1);
          }
      }
  
      /////////////////////////////////////////////////////////////////////////////////
      static int[] nextIntArray(int n) {
          int[] arr = new int[n];
          int i = 0;
          while (i < n) {
              arr[i++] = ni();
          }
          return arr;
      }
  
      static long[] nextLongArray(int n) {
          long[] arr = new long[n];
          int i = 0;
          while (i < n) {
              arr[i++] = nl();
          }
          return arr;
      }
  
      static int[] nextIntArray1(int n) {
          int[] arr = new int[n + 1];
          int i = 1;
          while (i <= n) {
              arr[i++] = ni();
          }
          return arr;
      }
  
      /////////////////////////////////////////////////////////////////////////////////
      static int ni() {
          return sc.nextInt();
      }
  
      static long nl() {
          return sc.nextLong();
      }
  
      static double nd() {
          return sc.nextDouble();
      }
  
      /////////////////////////////////////////////////////////////////////////////////
      static void pl() {
          pw.println();
      }
  
      static void p(Object o) {
          pw.print(o + " ");
      }
  
      static void pl(Object o) {
          pw.println(o);
      }
  
      static void psb(StringBuilder sb) {
          pw.print(sb);
      }
  
      static void pa(Object arr[]) {
          for (Object o : arr) {
              p(o);
          }
          pl();
      }
  
      static void pa(int arr[]) {
          for (int o : arr) {
              p(o);
          }
          pl();
      }
  
      static void pa(long arr[]) {
          for (long o : arr) {
              p(o);
          }
          pl();
      }
  
      static void pa(double arr[]) {
          for (double o : arr) {
              p(o);
          }
          pl();
      }
  
      static void pa(char arr[]) {
          for (char o : arr) {
              p(o);
          }
          pl();
      }
  
      static void pa(List list) {
          for (Object o : list) {
              p(o);
          }
          pl();
      }
  
      static void pa(Object[][] arr) {
  
          for (int i = 0; i < arr.length; ++i) {
              for (Object o : arr[i]) {
                  p(o);
              }
              pl();
          }
      }
  
      static void pa(int[][] arr) {
          for (int i = 0; i < arr.length; ++i) {
              for (int o : arr[i]) {
                  p(o);
              }
              pl();
          }
      }
  
      static void pa(long[][] arr) {
          for (int i = 0; i < arr.length; ++i) {
              for (long o : arr[i]) {
                  p(o);
              }
              pl();
          }
      }
  
      static void pa(char[][] arr) {
          for (int i = 0; i < arr.length; ++i) {
              for (char o : arr[i]) {
                  p(o);
              }
              pl();
          }
      }
  
      static void pa(double[][] arr) {
          for (int i = 0; i < arr.length; ++i) {
              for (double o : arr[i]) {
                  p(o);
              }
              pl();
          }
      }
  
  /////////////////////////////////////////////////////////////////////////////////
      static void print(Object s) {
          System.out.println(s);
      }
  
      /////////////////////////////////////////////////////////////////////////////////
      //-----------HritikScanner class for faster input----------//
      static class HritikScanner {
  
          BufferedReader br;
          StringTokenizer st;
  
          public HritikScanner() {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
  
      //////////////////////////////////////////////////////////////////
      public static class Pair implements Comparable<Pair> {
  
          int num, row, col;
  
          Pair(int num, int row, int col) {
              this.num = num;
              this.row = row;
              this.col = col;
          }
  
          public int get1() {
              return num;
          }
  
          public int get2() {
              return row;
          }
  
          public int compareTo(Pair A) {
              return this.num - A.num;
          }
  
          public String toString() {
              return num + " " + row + " " + col;
          }
      }
  
      //////////////////////////////////////////////////////////////////
      // Function to return gcd of a and b time complexity O(log(a+b))
      static long gcd(long a, long b) {
          if (a == 0) {
              return b;
          }
          return gcd(b % a, a);
      }
  
      // method to return LCM of two numbers 
      static long lcm(int a, int b) {
          return (a / gcd(a, b)) * b;
      }
  
      //////////////////////////////////////////////////////////////////
      static boolean isPrime(long n) {
          // Corner cases 
          if (n <= 1) {
              return false;
          }
          if (n <= 3) {
              return true;
          }
  
          // This is checked so that we can skip  
          // middle five numbers in below loop 
          if (n % 2 == 0 || n % 3 == 0) {
              return false;
          }
  
          for (long i = 5; i * i <= n; i = i + 6) {
              if (n % i == 0 || n % (i + 2) == 0) {
                  return false;
              }
          }
  
          return true;
      }
      //////////////////////////////////////////////////////////////////
  
      static boolean isPowerOfTwo(long n) {
          if (n == 0) {
              return false;
          }
  
          return (long) (Math.ceil((Math.log(n) / Math.log(2))))
                  == (long) (Math.floor(((Math.log(n) / Math.log(2)))));
      }
  
      public static long getFact(int n) {
          long ans = 1;
          while (n > 0) {
              ans *= n;
              ans %= MOD;
              n--;
          }
          return ans;
      }
  
      public static long pow(long n, int pow) {
          if (pow == 0) {
              return 1;
          }
          long temp = pow(n, pow / 2) % MOD;
          temp *= temp;
          temp %= MOD;
          if (pow % 2 == 1) {
              temp *= n;
          }
          temp %= MOD;
          return temp;
  
      }
  
      public static long nCr(int n, int r) {
          long ans = 1;
          int temp = n - r;
          while (n > temp) {
              ans *= n;
              ans %= MOD;
              n--;
          }
          ans *= pow(getFact(r) % MOD, MOD - 2) % MOD;
          ans %= MOD;
          return ans;
      }
  
      //////////////////////////////////////////////////////////////////
      // method returns Nth power of A 
      static double nthRoot(int A, int N) {
  
          // intially guessing a random number between 
          // 0 and 9 
          double xPre = Math.random() % 10;
  
          // smaller eps, denotes more accuracy 
          double eps = 0.001;
  
          // initializing difference between two 
          // roots by INT_MAX 
          double delX = 2147483647;
  
          // xK denotes current value of x 
          double xK = 0.0;
  
          // loop untill we reach desired accuracy 
          while (delX > eps) {
              // calculating current value from previous 
              // value by newton's method 
              xK = ((N - 1.0) * xPre
                      + (double) A / Math.pow(xPre, N - 1)) / (double) N;
              delX = Math.abs(xK - xPre);
              xPre = xK;
          }
  
          return xK;
      }
  
  }
  