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: import java.io.*;
  import java.util.*;
  
  
  public class ComdeFormces {
  	public static void main(String[] args) throws Exception{
  		// TODO Auto-generated method stub
  		FastReader sc=new FastReader();
  		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
  		int t=sc.nextInt();
  		while(t--!=0) {
  		int n=sc.nextInt();
  		long a[]=new long[n];
  		long min=Long.MAX_VALUE;
  		long max=Long.MIN_VALUE;
  		for(int i=0;i<n;i++) {
  			a[i]=sc.nextLong();
  			min=Math.min(min, a[i]);
  			max=Math.max(max, a[i]);
  		}
  		log.write(bsv(a,min,max)+"");
  		log.write("\n");
  		log.flush();
  		}
  		
  		}
  static String rev(String s) {
  	char temp[]=s.toCharArray();
  	for(int i=0;i<temp.length/2;i++) {
  		char tp=temp[i];
  		temp[i]=temp[temp.length-1-i];
  		temp[temp.length-1-i]=tp;
  		
  	}
  	return String.valueOf(temp);
  }	
  static long bsv(long a[],long min,long max) {
  	long ans=-1;
  	while(min<=max) {
  		long mid=min+(max-min)/2;
  		long an=solvess(a,mid);
  //	    System.out.println("an="+an+"mid="+mid);
  		if(an==mid) {
  			ans=Math.max(ans,an);
  			min=mid+1;
  		}
  		else if(an>mid)min=mid+1;
  		else if(an<mid)max=mid-1;
  		
  	}
  	return ans;
  }		
  static long solvess(long aa[],long el) {
  	long a[]=new long[aa.length];
  	long min=Long.MAX_VALUE;
  	for(int i=0;i<a.length;i++ ) {
  		a[i]=aa[i];
  		min=Math.min(min, aa[i]);
  	}
  	boolean ans=true;
  	long val[]=new long[a.length];
  	for(int i=a.length-1;i>=2;i--) {
  		if(a[i]+val[i]>el) {
  			if(val[i]>=el) {
  			long df=a[i];
  			a[i]-=df;
  			val[i-1]+=(df/3);
  			val[i-2]+=2*(df/3);
  			a[i]+=df%3;
  			}
  			else {
  			 	long df=a[i]+val[i]-el;
  			 	val[i-1]+=(df/3);
  				val[i-2]+=2*(df/3);
  				a[i]-=df;
  				a[i]+=df%3;
  			}
  		}
  		
  	}
  	for(int i=0;i<a.length;i++) {
  		a[i]+=val[i];
  	}
  	
  	long min2=Long.MAX_VALUE;
  	for(int i=0;i<a.length;i++) {
  		min2=Math.min(min2, a[i]);
  	}
  	return min2;
  	
  
  	
  }	
  static int bsd(ArrayList<LinkedList<Integer>> arr, int val,int el) {
  	
  		int s=0;
  	    int e=arr.size()-1;
  	    int ptr=0;
  	    if(val==1)ptr=1;
  	    while(s<=e) {
  	    	int m=s+(e-s)/2;
  	    	if(arr.get(m).get(ptr)==el)return m;
  	    	else if(arr.get(m).get(ptr)<el)s=m+1;
  	    	else e=m-1;
  	    }
  	    return -1;
  	
  	
  }
  static int bs(ArrayList<pair> arr,int el) {
  	int start=0;
  	int end=arr.size()-1;
  	while(start<=end) {
  		int mid=start+(end-start)/2;
  		if(arr.get(mid).a==el)return mid;
  		else if(arr.get(mid).a<el)start=mid+1;
  		else end=mid-1;
  	}
     if(start>arr.size()-1)return -2;
     return -1;
  }	
  static String eval(String s, long bs, long be,long k) {
  	String ans="";
  	for(int i=s.length()-1;i>=0;i--) {
  		if(s.charAt(i)=='a') {
  			ans="a"+ans;
  		}
  		else if(be>0){
  			
  			if(be>k) {
  				for(int j=0;j<k;j++)ans="b"+ans;
  				be-=k;
  			}
  			else {
  				for(int j=0;j<be;j++)ans="b"+ans;
  				be=0;
  			} 
  			
  		}
  	}
  	for(int i=0;i<bs;i++)ans="b"+ans;
  	return ans;
  	
  }	
  static int[][] slv() {
  	int r=200001;
  	int bits=(int)(Math.log(r)/Math.log(2))+1;
  	int cnt[][]=new int[r+1][bits];
  	for(int i=1;i<=r;i++) {
  		int temp=i;
  		int j=0;
  		int min=Integer.MAX_VALUE;
  		while(j<bits) {
  			int tval=1&temp;
  			temp>>=1;
  	        if(tval==0)cnt[i][j]=cnt[i-1][j]+1;
  	        else {
  	        	 cnt[i][j]=cnt[i-1][j];
  	        }
  	        j++;
  		}
  	}
  	return cnt;
  	
  }	
  static long find(int s,long a[]) {
  	if(s>=a.length)return -1;
  	long num=a[s];
  	for(int i=s;i<a.length;i+=2) {
  		num=gcd(num,a[i]);
  		if(num==1 || num==0)return -1;
  	}
  	return  num;
  }	
  static long gcd(long a,long b) {
  	if(b==0)return a;
  	else return gcd(b,a%b);
  }	
  static long factmod(long n,long mod,long img) {
  	if(n==0)return 1;
  	long ans=1;
  	long temp=1;
  	while(n--!=0) {
  		if(temp!=img) {
  		ans=((ans%mod)*((temp)%mod))%mod;
  		}
  		temp++;
  	}
  	return ans%mod;
  }	
  static long eval(ArrayList<Integer> a, int k) {
  	if(a.size()<1 )return 0;
  	int i=a.size()-1;
  	long ans=0;
  	while(i>=0) {
  		int temp=k;
  		int prev=0;
  		while(temp--!=0 && i>=0) {
  			ans+=Math.abs(a.get(i)-prev);
  			if(temp==0 || i==0)ans+=a.get(i);
  			prev=a.get(i);
  			i--;
  		}
  	}
  	return ans;
  }	
  static int bs(long a[] ,long num) {
  	int start=0;
  	int end=a.length-1;
      while(start<=end) {
      	int mid=start+(end-start)/2;
      	if(a[mid]==num) {
      		return mid;
      	}
      	else if(a[mid]<num)start=mid+1;
      	else end=mid-1;
      
      }
      return start;
  }	
  	
  	
  //utils	
  public static class trip{
  	int a,b,c;
  	public trip(int a,int b,int c) {
  		this.a=a;
  		this.b=b;
  		this.c=c;
  	}
  	public int compareTo(trip q) {
  		return this.c-q.c;
  	}
  }	
  	static void mergesort(int[] a,int start,int end) {
  		if(start>=end)return;
  		int mid=start+(end-start)/2;
  		mergesort(a,start,mid);
  		mergesort(a,mid+1,end);
  		merge(a,start,mid,end);
  	}
  	static void merge(int []a, int start,int mid,int end) {
  		int ptr1=start;
  		int ptr2=mid+1;
  		int b[]=new int[end-start+1];
  		int i=0;
  		while(ptr1<=mid && ptr2<=end) {
  			if(a[ptr1]<=a[ptr2]) {
  				b[i]=a[ptr1];
  				ptr1++;
  				i++;
  			}
  			else {
  				b[i]=a[ptr2];
  				ptr2++;
  				i++;
  			}
  		}
  		while(ptr1<=mid) {
  			b[i]=a[ptr1];
  			ptr1++;
  			i++;
  		}
  		while(ptr2<=end) {
  			b[i]=a[ptr2];
  			ptr2++;
  			i++;
  		}
  		for(int j=start;j<=end;j++) {
  			a[j]=b[j-start];
  		}
  	}
  	public static class FastReader {
  
  		BufferedReader b;
  		StringTokenizer s;
  		public FastReader() {
  			b=new BufferedReader(new InputStreamReader(System.in));
  		}
  		String next() {
  			while(s==null ||!s.hasMoreElements()) {
  				try {
  					s=new StringTokenizer(b.readLine());
  				}
  				catch(IOException e) {
  					e.printStackTrace();
  				}
  			}
  			return s.nextToken();
  		}
  		public int nextInt() {
  			return Integer.parseInt(next());
  		}
  		public long nextLong() {
  			return Long.parseLong(next());
  		}
  		public double nextDouble() {
  			return Double.parseDouble(next());
  		}
  		String nextLine() {
  			String str="";
  			try {
  				str=b.readLine();
  			}
  			catch(IOException e) {
  				e.printStackTrace();
  			}
  			return str;
  		}
  		boolean hasNext() {
  		    if (s != null && s.hasMoreTokens()) {
  		        return true;
  		    }
  		    String tmp;
  		    try {
  		        b.mark(1000);
  		        tmp = b.readLine();
  		        if (tmp == null) {
  		            return false;
  		        }
  		        b.reset();
  		    } catch (IOException e) {
  		        return false;
  		    }
  		    return true;
  		}
  }
  public static class pair{
  	int a;
  	int b;
  	public pair(int a,int b) {
  		this.a=a;
  		this.b=b;
  	}
  	public int compareTo(pair b) {
  		return this.a-b.a;
  	}
  	public int compareToo(pair b) {
  		if(this.a!=b.a)return this.a-b.a;
  		else {
  			return b.b-this.b;
  		}
  	}
  }	
  }
  