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: //jai Shree Krishna
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.IOException;
  import java.util.Collections;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.Comparator;
  import java.io.OutputStreamWriter;
  import java.util.ArrayList;
  import java.util.StringTokenizer;
  public class C{
  // author: Tarun Verma
  	static FastScanner sc = new FastScanner();
  	static int inf = Integer.MAX_VALUE;
  	static long mod = 1000000007;
  	static BufferedWriter output = new BufferedWriter(
  			new OutputStreamWriter(System.out));
  	static PrintWriter out=new PrintWriter(System.out);
  	/* Common Mistakes By Me
  	 * make sure to read the bottom part of question
  	 * special cases (n=1?)
  	 * in BIT MASKING try don't forget a^b=c == a^c=b
  	 * READ READ AND READ THE Test Cases VERY PROPERLY AND NEVER BE OVERCONFIDENT
  	 * Always Reset vis,adj array upto n+1 otherwise can cause TLE
  	 * Try to see array from back in increase and decrease questions
  	 */
  	public static void solve() {
  		int n = sc.nextInt();
  		long a[] = sc.readLongArray(n);
  		
  		long l = 0;
  		long r = (long) 1e9;
  		
  		long ans = -1;
  		while(l != r) {
  //			System.out.println("in");
  			long mid = (l+ r + 1) / 2;
  			if(isPossible(a, mid, n)) {
  				ans = mid;
  				l = mid;
  			} else {
  				r = mid -1;
  			}
  		}
  		System.out.println(ans);
  	}
  	
  	static boolean isPossible(long a[], long target, int n) {
  		
  		long b[] = new long[n];
  		for(int i =0;i<n;i++) b[i] = a[i];
  		for(int i = n-1;i>=2;i--) {
  			if(b[i] < target) return false;
  			long tmp = (b[i] - target) / 3 * 3;
  			tmp = min(tmp, a[i]);
  			b[i] -= tmp;
  			b[i-1] += tmp / 3;
  			b[i-2] += tmp / 3 * 2;
  		}
  		if(b[0] < target || b[1] < target) return false;
  		return true;
  	}
  	public static void main(String[] args) {
  		int t = 1;
  		t = sc.nextInt();
  		outer: for (int tt = 0; tt < t; tt++) {
  			solve();
  		}
  	}
  	
  ////////////////////////////////////////////////////////////////////////////////////
  ////////////////////DO NOT BELOW THIS LINE //////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////
  	static Comparator<pair> comp = new Comparator<pair>() {
  		@Override
  		public int compare(pair o1, pair o2) {
  			if(o1.fr == o2.fr) {
  				return o1.sc - o2.sc;
  			}
  			return o1.fr - o2.fr;
  		}
  	};
  	static int max(int a, int b) { return Math.max(a, b);} 
  	static int min(int a, int b) {return Math.min(a, b);}
  	static long max(long a, long b){return Math.max(a, b);}
  	static long min(long a, long b) {return Math.min(a, b);}
  	static void sort(int arr[]) {
  		ArrayList<Integer> a = new ArrayList<Integer>();
  		for(int i: arr) a.add(i);
  		Collections.sort(a);
  		for(int i=0;i<arr.length;i++) arr[i] = a.get(i);
  	}
  	static void sort(long arr[]) {
  		ArrayList<Long> a = new ArrayList<Long>();
  		for(long i: arr) a.add(i);
  		Collections.sort(a);
  		for(int i=0;i<arr.length;i++) arr[i] = a.get(i);
  	}
  	static int abs(int a) {return Math.abs(a);}
  	static long abs(long a) {return Math.abs(a);}
  	static int gcd(int a, int b) {
  		if (b == 0)
  			return a;
  		return gcd(b, a % b);
  	}
  	static long gcd(long a, long b) {
  		if (b == 0)
  			return a;
  		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[] readLongArray(int n) {
  			long[] a = new long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
  		
  		int[][] read2dArray(int n, int m) {
  			int arr[][] = new int[n][m];
  			for (int i = 0; i < n; i++) {
  				for (int j = 0; j < m; j++) {
  					arr[i][j] = nextInt();
  				}
  			}
  			return arr;
  		}
  		
  		ArrayList<Integer> readArrayList(int n) {
  			ArrayList<Integer> arr = new ArrayList<Integer>();
  			for (int i = 0; i < n; i++) {
  				int a = nextInt();
  				arr.add(a);
  			}
  			return arr;
  		}
  		
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  	}
  	
  	static class pair {
  		int fr, sc;
  		
  		pair(int fr, int sc) {
  			this.fr = fr;
  			this.sc = sc;
  		}
  	}
  	
  ////////////////////////////////////////////////////////////////////////////////////	
  	
  }
  