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 com.company;
  
  import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  
  public final class Main {
  
      FastReader s;
  
      public static void main(String[] args) throws java.lang.Exception {
  
          new Main().run();
  
      }
  
      void run() {
          s = new FastReader();
          solve();
      }
  
  
  
  
      StringBuffer sb;
  
  
      void solve() {
  
          sb = new StringBuffer();
  
  
          for (int T = s.nextInt(); T > 0; T--)
          {
  
              start();
  
  
          }
  
  
          System.out.print(sb);
  
      }
  
  
  
      void start()
      {
            int n = s.nextInt();
            long arr[] = longArr(n);
  
            long i = Long.MAX_VALUE;
            long j = 0;
            for(long h : arr)
            {
                j+=h;
                i = Math.min(i,h);
            }
            j/=3;
  
            while(i<=j)
            {
                long mid = i + (j-i)/2;
  //              System.out.println(mid);
                if(check(arr,n,mid))
                {
                    i = mid+1;
                }
                else
                {
                    j = mid-1;
                }
            }
            sb.append(i-1+"\n");
  
  
  
  
      }
  
      boolean check(long arr1[], int n, long mid)
      {
          boolean ans = true;
          long arr[] = new long[n];
          for(int i = 0; i<n; i++)
              arr[i] = arr1[i];
  
          long gg[] = new long [n];
          for(int i = n-1; i>=2; i--)
          {
              if(arr[i]+gg[i] < mid)
              {
                  ans = false;
                  return  false;
              }
              else
              {
                  long diff = mid - gg[i];
  
                  if(diff > 0)
                  {
                      arr[i]-=diff;
                  }
                  long h = arr[i]/3;
                  gg[i-1]+=h;
                  gg[i-2]+=(2*h);
              }
          }
  
          if(arr[0]+gg[0] < mid)
              return false;
          if(arr[1]+gg[1] < mid)
              return false;
          return true;
  
      }
  
  
  
  
      class Pair {
          int a;
          int b;
  
          public Pair(int a, int b) {
              this.a = a;
              this.b = b;
          }
  
          void print() {
              System.out.println(a + " " + b);
          }
  
      }
  
      class segmentTree{
           int[] tree;
           int n;
           public segmentTree(int[] nums) {
               if (nums.length > 0) {
                   n = nums.length;
                   tree = new int[n * 2];
                   buildTree(nums);
               }
           }
  
           private void buildTree(int[] nums) {
               for (int i = n, j = 0;  i < 2 * n; i++,  j++)
                   tree[i] = nums[j];
               for (int i = n - 1; i > 0; --i)
                   tree[i] = tree[i * 2] + tree[i * 2 + 1];
           }
  
           void update(int pos, int val) {
               pos += n;
               tree[pos] = val;
               while (pos > 0) {
                   int left = pos;
                   int right = pos;
                   if (pos % 2 == 0) {
                       right = pos + 1;
                   } else {
                       left = pos - 1;
                   }
                   // parent is updated after child is updated
                   tree[pos / 2] = tree[left] + tree[right];
                   pos /= 2;
               }
           }
  
           public int sumRange(int l, int r) {
               // get leaf with value 'l'
               l += n;
               // get leaf with value 'r'
               r += n;
               int sum = 0;
               while (l <= r) {
                   if ((l % 2) == 1) {
                       sum += tree[l];
                       l++;
                   }
                   if ((r % 2) == 0) {
                       sum += tree[r];
                       r--;
                   }
                   l /= 2;
                   r /= 2;
               }
               return sum;
           }
  
       }
  
      int gcd(int a, int b) {
          if (b == 0)
              return a;
          return gcd(b, a % b);
      }
  
      long gcd(long a, long b) {
          if (b == 0)
              return a;
          return gcd(b, a % b);
      }
  
      long power(long x, long y, long p) {
          long res = 1;
  
  
          x = x % p;
  
          while (y > 0) {
  
              if ((y & 1) > 0)
                  res = (res * x) % p;
  
  
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
  
      int find(int dsu[], int i) {
          if (dsu[i] == i)
              return i;
          dsu[i] = find(dsu, dsu[i]);
          return dsu[i];
      }
  
      void union(int dsu[], int i, int j) {
          int a = find(dsu, i);
          int b = find(dsu, j);
          dsu[a] = b;
      }
  
      static void sort(int[] a) {
          ArrayList<Integer> l = new ArrayList<>();
          for (int i : a)
              l.add(i);
          Collections.sort(l);
          for (int i = 0; i < a.length; i++)
              a[i] = l.get(i);
      }
  
      static void sort(long[] a) {
          ArrayList<Long> l = new ArrayList<>();
          for (long i : a)
              l.add(i);
          Collections.sort(l);
          for (int i = 0; i < a.length; i++)
              a[i] = l.get(i);
      }
  
      static String sort(String s) {
          Character ch[] = new Character[s.length()];
          for (int i = 0; i < s.length(); i++) {
              ch[i] = s.charAt(i);
          }
          Arrays.sort(ch);
          StringBuffer st = new StringBuffer("");
          for (int i = 0; i < s.length(); i++) {
              st.append(ch[i]);
          }
          return st.toString();
      }
  
      // long array input
      public long[] longArr(int len) {
          // long arr input
          long[] arr = new long[len];
          String[] strs = s.nextLine().trim().split("\\s+");
          for (int i = 0; i < len; i++) {
              arr[i] = Long.parseLong(strs[i]);
  
          }
          return arr;
      }
  
      // int arr input
      public int[] intArr(int len) {
          // long arr input
          int[] arr = new int[len];
          String[] strs = s.nextLine().trim().split("\\s+");
          for (int i = 0; i < len; i++) {
              arr[i] = Integer.parseInt(strs[i]);
  
          }
          return arr;
      }
  
      public void printArray(int[] A) {
          System.out.println(Arrays.toString(A));
      }
  
      public void printArray(long[] A) {
          System.out.println(Arrays.toString(A));
      }
  
  
  
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() {
              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;
          }
      }
  
  }
  