description: There are n heaps of stone. The i-th heap has h_i stones. You want to change the number of stones in the heap by performing the following process once: 
  
    * You go through the heaps from the 3-rd heap to the n-th heap, in this order. 
    * Let i be the number of the current heap. 
    * You can choose a number d (0 ≤ 3 ⋅ d ≤ h_i), move d stones from the i-th heap to the (i - 1)-th heap, and 2 ⋅ d stones from the i-th heap to the (i - 2)-th heap. 
    * So after that h_i is decreased by 3 ⋅ d, h_{i - 1} is increased by d, and h_{i - 2} is increased by 2 ⋅ d. 
    * You can choose different or same d for different operations. Some heaps may become empty, but they still count as heaps. 
  
  
  
  What is the maximum number of stones in the smallest heap after the process?
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^5). Description of the test cases follows.
  
  The first line of each test case contains a single integer n (3 ≤ n ≤ 2 ⋅ 10^5).
  
  The second lines of each test case contains n integers h_1, h_2, h_3, …, h_n (1 ≤ h_i ≤ 10^9).
  
  It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case, print the maximum number of stones that the smallest heap can contain.
  
  Example
  
  Input
  
  
  4
  4
  1 2 10 100
  4
  100 100 100 1
  5
  5 1 1 1 8
  6
  1 2 3 4 5 6
  
  
  Output
  
  
  7
  1
  1
  3
  
  Note
  
  In the first test case, the initial heap sizes are [1, 2, 10, 100]. We can move the stones as follows. 
  
    * move 3 stones and 6 from the 3-rd heap to the 2-nd and 1 heap respectively. The heap sizes will be [7, 5, 1, 100]; 
    * move 6 stones and 12 stones from the last heap to the 3-rd and 2-nd heap respectively. The heap sizes will be [7, 17, 7, 82]. 
  
  
  
  In the second test case, the last heap is 1, and we can not increase its size.
  
  In the third test case, it is better not to move any stones.
  
  In the last test case, the final achievable configuration of the heaps can be [3, 5, 3, 4, 3, 3].
solution: // remove this when done
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  import java.util.StringTokenizer;
  
  public class c {
      public static void main(String[] args) {
          FastScanner fs = new FastScanner();
          PrintWriter pw = new PrintWriter(System.out);
  
          long t = fs.nextInt();
          while(t-- >0) {
              // get input
              int n = fs.nextInt();
              int[] heaps = new int[n];
              int max = -1;
              for (int i = 0; i < n; i++) {
                  heaps[i] = fs.nextInt();
                  max = Math.max(max, heaps[i]);
              }
              // solve
              // use bn search
              int lo = 0;
              int hi = max;
              while ((lo + 1) < hi) {
                      int mid= lo + ((hi - lo) / 2);
                  if (isValidMin(heaps, n, mid)) {
                      // possible to increase
                      lo = mid;
                  } else {
                      hi = mid - 1;
                  }
              }
              System.out.println(isValidMin(heaps, n, lo + 1) ? lo + 1 : lo);
          }
      }
  
      static boolean isValidMin(int[] heaps, int n, int min) {
          // how to check if min is valid
          // start from back
          int[] heapAfter = heaps.clone();
          for (int i = n - 1; i >= 2; i--) {
              if (heapAfter[i] < min) {
                  return false;
              }
              // how much to give? as much st. still have k
              int toGive = Math.min(heapAfter[i] - min, heaps[i]);
              int d = toGive / 3;
              heapAfter[i - 1] = heapAfter[i - 1] + d;
              heapAfter[i - 2] = heapAfter[i - 2] + 2 * d;
          }
          return heapAfter[0] >= min && heapAfter[1] >= min;
      }
  
      // make some container class with Comparable
  
  
      static List<Integer> sieve(int end) {
          List<Integer> res = new ArrayList<>();
          boolean[] notPrime = new boolean[end + 1];
          notPrime[0] = true;
          notPrime[1] = true;
          for (int i = 2; i < end; i++) {
              if (!notPrime[i]) {
                  res.add(i);
                  for (int j = i; i * j <= end; j++) {
                      notPrime[i * j] = true;
                  }
              }
          }
          return res;
      }
  
      static long logbase2(long val) {
          int res = 0;
          while (val >> (res + 1) > 0) {
              res += 1;
          }
          return res;
      }
  
      static long pow(long base, long pow) {
          long res = 1;
  
          while (pow > 0) {
              if ((pow & 1) == 1) {
                  res = base * res;
              }
              base = base * base;
              pow = pow / 2;
          }
          return res;
      }
  
      static long lcm(long a, long b) {
          return (a * b) / gcd(a, b);
      }
  
      // euclidean gcd
      static long gcd(long a, long b) {
          if (a == 0) {
              return b;
          } else if (b == 0) {
              return a;
          } else {
              return gcd(b, a % b);
          }
      }
  
      static class FastScanner {
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          StringTokenizer st=new StringTokenizer("");
          String next() {
              while (!st.hasMoreTokens())
                  try {
                      st=new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
          int[] readArray(int n) {
              int[] a=new int[n];
              for (int i=0; i<n; i++) a[i]=nextInt();
              return a;
          }
          long nextLong() {
              return Long.parseLong(next());
          }
      }
  }
  