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 codeforces.round763div2;
  
  import java.io.*;
  import java.util.*;
  
  import static java.lang.Math.*;
  
  //Think through the entire logic before jump into coding!
  //If you are out of ideas, take a guess! It is better than doing nothing!
  //Read both C and D, it is possible that D is easier than C for you!
  
  //Be aware of integer overflow!
  //If you find an answer and want to return immediately, don't forget to flush before return!
  
  public class C {
      static InputReader in;
      static PrintWriter out;
  
      public static void main(String[] args) {
          //initReaderPrinter(true);
          initReaderPrinter(false);
          solve(in.nextInt());
          //solve(1);        
      }
  
      static void solve(int testCnt) {
          for (int testNumber = 0; testNumber < testCnt; testNumber++) {
              int n = in.nextInt();
              int[] h = in.nextIntArrayPrimitive(n);
              long sum = 0;
              for(int v : h) {
                  sum += v;
              }
              long l = 0, r = sum / n;
              while(l < r - 1) {
                  long mid = l + (r - l) / 2;
                  if(check(h, mid)) {
                      l = mid;
                  }
                  else {
                      r = mid - 1;
                  }
              }
              if(check(h, r)) out.println(r);
              else out.println(l);
          }
          out.close();
      }
  
      static boolean check(int[] h, long k) {
          int[] hc = Arrays.copyOf(h, h.length);
          for(int i = hc.length - 1; i >= 2; i--) {
              if(hc[i] < k) return false;
              long maxLend = min(hc[i] - k, h[i]);
              hc[i - 1] += maxLend / 3;
              hc[i - 2] += maxLend / 3 * 2;
          }
          return min(hc[0], hc[1]) >= k;
      }
  
      static void initReaderPrinter(boolean test) {
          if (test) {
              try {
                  in = new InputReader(new FileInputStream("src/input.in"));
                  out = new PrintWriter(new FileOutputStream("src/output.out"));
              } catch (IOException e) {
                  e.printStackTrace();
              }
          } else {
              in = new InputReader(System.in);
              out = new PrintWriter(System.out);
          }
      }
  
      static class InputReader {
          BufferedReader br;
          StringTokenizer st;
  
          InputReader(InputStream stream) {
              try {
                  br = new BufferedReader(new InputStreamReader(stream), 32768);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
  
          String next() {
              while (st == null || !st.hasMoreTokens()) {
                  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;
          }
  
          Integer[] nextIntArray(int n) {
              Integer[] a = new Integer[n];
              for (int i = 0; i < n; i++) a[i] = nextInt();
              return a;
          }
  
          int[] nextIntArrayPrimitive(int n) {
              int[] a = new int[n];
              for (int i = 0; i < n; i++) a[i] = nextInt();
              return a;
          }
  
          int[] nextIntArrayPrimitiveOneIndexed(int n) {
              int[] a = new int[n + 1];
              for (int i = 1; i <= n; i++) a[i] = nextInt();
              return a;
          }
  
          Long[] nextLongArray(int n) {
              Long[] a = new Long[n];
              for (int i = 0; i < n; i++) a[i] = nextLong();
              return a;
          }
  
          long[] nextLongArrayPrimitive(int n) {
              long[] a = new long[n];
              for (int i = 0; i < n; i++) a[i] = nextLong();
              return a;
          }
  
          long[] nextLongArrayPrimitiveOneIndexed(int n) {
              long[] a = new long[n + 1];
              for (int i = 1; i <= n; i++) a[i] = nextLong();
              return a;
          }
  
          String[] nextStringArray(int n) {
              String[] g = new String[n];
              for (int i = 0; i < n; i++) g[i] = next();
              return g;
          }
  
          List<Integer>[] readGraphOneIndexed(int n, int m) {
              List<Integer>[] adj = new List[n + 1];
              for (int i = 0; i <= n; i++) {
                  adj[i] = new ArrayList<>();
              }
              for (int i = 0; i < m; i++) {
                  int u = nextInt();
                  int v = nextInt();
                  adj[u].add(v);
                  adj[v].add(u);
              }
              return adj;
          }
  
          List<Integer>[] readGraphZeroIndexed(int n, int m) {
              List<Integer>[] adj = new List[n];
              for (int i = 0; i < n; i++) {
                  adj[i] = new ArrayList<>();
              }
              for (int i = 0; i < m; i++) {
                  int u = nextInt() - 1;
                  int v = nextInt() - 1;
                  adj[u].add(v);
                  adj[v].add(u);
              }
              return adj;
          }
  
          /*
              A more efficient way of building an undirected graph using int[] instead of ArrayList to store each node's neighboring nodes.
              1-indexed.
           */
          int[][] buildUndirectedGraph(int nodeCnt, int edgeCnt) {
              int[] end1 = new int[edgeCnt], end2 = new int[edgeCnt];
              int[] edgeCntForEachNode = new int[nodeCnt + 1], idxForEachNode = new int[nodeCnt + 1];
              for (int i = 0; i < edgeCnt; i++) {
                  int u = in.nextInt(), v = in.nextInt();
                  edgeCntForEachNode[u]++;
                  edgeCntForEachNode[v]++;
                  end1[i] = u;
                  end2[i] = v;
              }
              int[][] adj = new int[nodeCnt + 1][];
              for (int i = 1; i <= nodeCnt; i++) {
                  adj[i] = new int[edgeCntForEachNode[i]];
              }
              for (int i = 0; i < edgeCnt; i++) {
                  adj[end1[i]][idxForEachNode[end1[i]]] = end2[i];
                  idxForEachNode[end1[i]]++;
                  adj[end2[i]][idxForEachNode[end2[i]]] = end1[i];
                  idxForEachNode[end2[i]]++;
              }
              return adj;
          }
  
          /*
              A more efficient way of building a directed graph using int[] instead of ArrayList to store each node's neighboring nodes.
              1-indexed.
           */
          int[][] buildDirectedGraph(int nodeCnt, int edgeCnt) {
              int[] from = new int[edgeCnt], to = new int[edgeCnt];
              int[] edgeCntForEachNode = new int[nodeCnt + 1], idxForEachNode = new int[nodeCnt + 1];
              //from u to v: u -> v
              for (int i = 0; i < edgeCnt; i++) {
                  int u = in.nextInt(), v = in.nextInt();
                  edgeCntForEachNode[u]++;
                  from[i] = u;
                  to[i] = v;
              }
              int[][] adj = new int[nodeCnt + 1][];
              for (int i = 1; i <= nodeCnt; i++) {
                  adj[i] = new int[edgeCntForEachNode[i]];
              }
              for (int i = 0; i < edgeCnt; i++) {
                  adj[from[i]][idxForEachNode[from[i]]] = to[i];
                  idxForEachNode[from[i]]++;
              }
              return adj;
          }
      }
  }