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.io.*;
  import java.math.BigInteger;
  import java.util.*;
  
  public class Main{
  
      static boolean[] primecheck = new boolean[1000002];
      //static ArrayList<Integer> adj[];
      //static int[] vis;
      //static long cnt = 0;
      static long mod = (long)1e9 + 7;
  
      public static void main(String[] args) {
          OutputStream outputStream = System.out;
          FastReader in = new FastReader();
          PrintWriter out = new PrintWriter(outputStream);
          PROBLEM solver = new PROBLEM();
          int t = 1;
          t = in.nextInt();
          for (int i = 0; i < t; i++) {
              solver.solve(in, out);
          }
          out.close();
      }
  
      static class PROBLEM {
  
          public void solve(FastReader in, PrintWriter out) {
  
              int n = in.nextInt();
              int[] a = in.readArray(n);
              int ans = 0;
  
              int l = 0, r = 1000000001;
  
              while(l<=r){
                  int mid = (l+r)/2;
                  if(check(mid, a)){
                      ans = mid;
                      l = mid+1;
                  }else r = mid-1;
              }
              out.println(ans);
          }
      }
  
      static boolean check(int x, int[] a){
  
          int[] b = Arrays.copyOf(a, a.length);
          for (int i = a.length-1; i > 1 ; i--) {
              if(b[i] < x) return false;
              int d = Math.min(b[i]-x, a[i])/3;
              b[i-1] += d;
              b[i-2] += 2*d;
          }
  
          //System.out.println(x + " " + Arrays.toString(b));
  
          return Math.min(b[0], b[1]) >= x;
  
      }
  
      static long sum(long n){
          return (n*(n+1))/2;
      }
  
      static void swap(int[] a, int l, int r) {
          int temp = a[l];
          a[l] = a[r];
          a[r] = temp;
      }
  
  //    static void dfs(int i){
  //        vis[i] = 1;
  //        cnt++;
  //
  //        for(int j: adj[i]){
  //            if(vis[j] == 0)
  //                dfs(j);
  //        }
  //    }
  
      static HashMap<Integer, Integer> initializeMap(int n){
          HashMap<Integer,Integer> hm = new HashMap<>();
          for (int i = 0; i <= n; i++) {
              hm.put(i, 0);
          }
          return hm;
      }
  
      static boolean isRegular(char[] c){
  
          Stack<Character> s = new Stack<>();
          for (char value : c) {
              if (s.isEmpty() && value == ')') return false;
  
              if (value == '(') s.push(value);
              else s.pop();
          }
  
          return s.isEmpty();
      }
  
      static ArrayList<ArrayList<Integer>> createAdj(int n, int e){
  
          FastReader in = new FastReader();
          ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
  
          for (int i = 0; i < n + 1; i++) {
              adj.add(new ArrayList<>());
          }
  
          for (int i = 0; i < e; i++) {
  
              int a = in.nextInt(), b = in.nextInt();
              System.out.println(a);
  
              adj.get(a).add(b);
              adj.get(b).add(a);
          }
  
  
          return adj;
      }
  
      static int binarySearch(int[] a, int l, int r, int x){
          if(r>=l){
              int mid = l + (r-l)/2;
  
              if(a[mid] == x) return mid;
  
              if(a[mid] > x) return binarySearch(a, l, mid-1, x);
              else return binarySearch(a,mid+1, r, x);
          }
          return -1;
      }
  
      static boolean isPalindromeI(int n){
  
          int d = 0;
          int y = n;
          while(y>0){
              d++;
              y/=10;
          }
  
          int[] a = new int[d];
          for (int i = 0; i < d; i++) {
              a[i] = n%10;
              n/=10;
          }
  
          System.out.println(Arrays.toString(a));
          for (int i = 0; i < d / 2; i++) {
              if(a[i] != a[d-i-1]) return false;
          }
          return true;
      }
  
      static long gcd(long a, long b) {
          if (b == 0) return a;
          return gcd(b, a % b);
      }
  
      static long lcm(long a, long b)
      {
          return (a / gcd(a, b)) * b;
      }
  
      static boolean isSquare(double a) {
          boolean isSq = false;
          double b = Math.sqrt(a);
          double c = Math.sqrt(a) - Math.floor(b);
  
          if (c == 0) isSq = true;
  
          return isSq;
      }
  
      static long fast_pow(long a, long b) { //Jeel bhai OP
          if(b == 0)
              return 1L;
  
          long val = fast_pow(a, b / 2);
  
          if(b % 2 == 0)
              return val * val % mod;
          else
              return val * val % mod * a % mod;
      }
  
      static int exponentMod(int A, int B, int C) {
  
          // Base cases
          if (A == 0)
              return 0;
          if (B == 0)
              return 1;
  
          // If B is even
          long y;
          if (B % 2 == 0) {
              y = exponentMod(A, B / 2, C);
              y = (y * y) % C;
          }
  
          // If B is odd
          else {
              y = A % C;
              y = (y * exponentMod(A, B - 1, C) % C) % C;
          }
  
          return (int) ((y + C) % C);
      }
  
  
      static class Pair implements Comparable<Pair>{
  
          int x;
          int y;
  
          Pair(int x, int y){
              this.x = x;
              this.y = y;
          }
  
          public int compareTo(Pair o){
              int ans = Integer.compare(x, o.x);
              if(o.x == x) ans = Integer.compare(y, o.y);
  
              return ans;
          }
      }
  
      static class Tuple implements Comparable<Tuple>{
  
          int x, y, id;
  
          Tuple(int x, int y, int id){
              this.x = x;
              this.y = y;
              this.id = id;
          }
  
          public int compareTo(Tuple o){
              int ans = Integer.compare(x, o.x);
              if(o.x == x) ans = Integer.compare(y, o.y);
  
              return ans;
          }
      }
  
  //    public static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
  //        public U x;
  //        public V y;
  //
  //        public Pair(U x, V y) {
  //            this.x = x;
  //            this.y = y;
  //        }
  //
  //        public int hashCode() {
  //            return (x == null ? 0 : x.hashCode() * 31) + (y == null ? 0 : y.hashCode());
  //        }
  //
  //        public boolean equals(Object o) {
  //            if (this == o)
  //                return true;
  //            if (o == null || getClass() != o.getClass())
  //                return false;
  //            Pair<U, V> p = (Pair<U, V>) o;
  //            return (x == null ? p.x == null : x.equals(p.x)) && (y == null ? p.y == null : y.equals(p.y));
  //        }
  //
  //        public int compareTo(Pair<U, V> b) {
  //            int cmpU = x.compareTo(b.x);
  //            return cmpU != 0 ? cmpU : y.compareTo(b.y);
  //        }
  //
  //        public int compareToY(Pair<U, V> b) {
  //            int cmpU = y.compareTo(b.y);
  //            return cmpU != 0 ? cmpU : x.compareTo(b.x);
  //        }
  //
  //        public String toString() {
  //            return String.format("(%s, %s)", x.toString(), y.toString());
  //        }
  //
  //    }
  
      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());
          }
  
          char nextChar() {
              return next().charAt(0);
          }
  
          boolean nextBoolean() {
              return !(nextInt() == 0);
          }
          // boolean nextBoolean(){return Boolean.parseBoolean(next());}
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
  
          public int[] readArray(int size) {
              int[] array = new int[size];
              for (int i = 0; i < size; i++) array[i] = nextInt();
              return array;
          }
  
      }
  
      private static int[] mergeSort(int[] array) {
  
          //array.length replaced with ctr
          int ctr = array.length;
          if (ctr <= 1) {
              return array;
          }
  
          int midpoint = ctr / 2;
  
          int[] left = new int[midpoint];
          int[] right;
  
          if (ctr % 2 == 0) {
              right = new int[midpoint];
          } else {
              right = new int[midpoint + 1];
          }
  
          for (int i = 0; i < left.length; i++) {
              left[i] = array[i];
          }
  
          for (int i = 0; i < right.length; i++) {
              right[i] = array[i + midpoint];
          }
  
          left = mergeSort(left);
          right = mergeSort(right);
  
          int[] result = merge(left, right);
  
          return result;
      }
  
      private static int[] merge(int[] left, int[] right) {
  
          int[] result = new int[left.length + right.length];
          int leftPointer = 0, rightPointer = 0, resultPointer = 0;
  
          while (leftPointer < left.length || rightPointer < right.length) {
  
              if (leftPointer < left.length && rightPointer < right.length) {
  
                  if (left[leftPointer] < right[rightPointer]) {
                      result[resultPointer++] = left[leftPointer++];
                  } else {
                      result[resultPointer++] = right[rightPointer++];
                  }
              } else if (leftPointer < left.length) {
                  result[resultPointer++] = left[leftPointer++];
              } else {
                  result[resultPointer++] = right[rightPointer++];
              }
          }
          return result;
      }
  
      public static void Sieve(int n) {
  
          Arrays.fill(primecheck, true);
          primecheck[0] = false;
          primecheck[1] = false;
  
          for (int i = 2; i * i < n + 1; i++) {
              if (primecheck[i]) {
                  for (int j = i * 2; j < n + 1; j += i) {
                      primecheck[j] = false;
                  }
              }
          }
      }
  }
  
  
  