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: // package c1623;
  
  import java.io.File;
  import java.lang.invoke.MethodHandles;
  import java.util.Random;
  import java.util.Scanner;
  
  //
  // Codeforces Round #763 (Div. 2) 2021-12-28 05:35
  // C. Balanced Stone Heaps
  // https://codeforces.com/contest/1623/problem/C
  // time limit per test 1 second; memory limit per test 256 megabytes
  // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class\s+(\w+).*'
  //
  // 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 the following process:
  //  * You go through the heaps from the 3-rd heap to the n-th heap.
  //  * 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.
  //
  // 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].
  //
  public class C1623C {
    static final int MOD = (int)1e9+7;
    static final Random RAND = new Random();
  
    static int solve(int[] h) {
      int n = h.length;
      int min = h[0];
      int max = h[0];
      for (int v : h) {
        min = Math.min(min, v);
        max = Math.max(max, v);
      }
      int low = min;
      int high = max;
      int ans = low;
      while (low <= high) {
        int mid = low + (high - low) / 2;
        if (isOk(h, mid)) {
          low = mid + 1;
          ans = Math.max(ans, mid);
        } else {
          high = mid - 1;
        }
      }
      myAssert(!isOk(h, ans + 1));
      return ans;
    }
  
    // Is maximal minimal being mid OK?
    static boolean isOk(int[] h, int mid) {
      int n = h.length;
      // evaluate backwards with d1 and d2 being the value of d for i+1 and i+2 respectively.
      long d2 = 0;
      long d1 = 0;
      for (int i = n-1; i >= 2; i--) {
        long v = h[i] + d1 + d2 * 2;
        if (v < mid) {
          return false;
        }
        // Let d be the maximal contribution from current to previous.
        //   v - 3d >= mid, so d <= (v - mid) / 3, however d is also limited by h[i]/3, so we have:
        long d = Math.min(h[i] / 3, (v - mid) / 3);
        // System.out.format("    mid:%3d i:%d d:%3d\n", mid, i, d);
        d2 = d1;
        d1 = d;
        myAssert(v - d * 3 >= mid);
        myAssert(d <= h[i] / 3);
        myAssert(d2 >= 0 && d1 >= 0);
      }
      // h0 and h1 are special (only accept but can not make contributions)
      //   0   1   2   3
      //       <----- d2
      //       <----- d2
      //       <-- d1
      //   <------ d1
      //   <------ d1
      if (h[1] + d2 * 2 + d1 < mid || h[0] + d1 * 2 < mid) {
        return false;
      }
      myAssert(h[0] + d1 * 2 >= mid);
      myAssert(h[1] + d2 * 2 + d1 >= mid);
      return true;
    }
  
    static void myAssert(boolean cond) {
      if (!cond) {
        throw new RuntimeException("Unexpected");
      }
    }
  
    static String trace(int[] a) {
      StringBuilder sb = new StringBuilder();
      for (int v : a) {
       if (sb.length() > 0) {
         sb.append(' ');
       }
        sb.append(v);
      }
      return sb.toString();
    }
  
    static void doTest() {
      for (int j = 0; j < 50; j++) {
        int n = 1000;
        int[] h = new int[n];
        final int bound = (int) 1e9;
        for (int i = 0; i < n; i++) {
          h[i] = 1 + RAND.nextInt(bound);
        }
        int ans = solve(h);
        System.out.println(ans);
      }
      System.exit(0);
    }
  
    public static void main(String[] args) {
      // doTest();
      Scanner in = getInputScanner();
      int T = in.nextInt();
      for (int t = 1; t <= T; t++) {
        int n = in.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
          h[i] = in.nextInt();
        }
        int ans = solve(h);
        System.out.println(ans);
      }
      in.close();
    }
  
    static Scanner getInputScanner() {
      try {
        final String USERDIR = System.getProperty("user.dir");
        final String CNAME = MethodHandles.lookup().lookupClass().getSimpleName();
        final File fin = new File(USERDIR + "/io/c" + CNAME.substring(1,5) + "/" + CNAME + ".in");
        return fin.exists() ? new Scanner(fin) : new Scanner(System.in);
      } catch (Exception e) {
        return new Scanner(System.in);
      }
    }
  }
  