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: #!/usr/bin/env python
  from __future__ import division, print_function
  from collections import defaultdict
  
  import os
  import sys
  from io import BytesIO, IOBase
  
  if sys.version_info[0] < 3:
      from __builtin__ import xrange as range
      from future_builtins import ascii, filter, hex, map, oct, zip
  
  def chk(m,um,mc,umc):
      ans=float("Inf")
      if(m<0 or um<0 or mc<0 or umc<0):
          return ans
      if(m%2==1 and mc==1+m-mc):
          ans=min(ans,m)
      if(um%2==0 and umc==um-umc):
          ans=min(ans,um)
      return ans
  
  from types import GeneratorType
  
  
  def bootstrap(f, stack=[]):
      def wrappedfunc(*args, **kwargs):
          if stack:
              return f(*args, **kwargs)
          else:
              to = f(*args, **kwargs)
              while True:
                  if type(to) is GeneratorType:
                      stack.append(to)
                      to = next(to)
                  else:
                      stack.pop()
                      if not stack:
                          break
                      to = stack[-1].send(to)
              return to
  
      return wrappedfunc
  
  @bootstrap
  def dfs(i,g,vis,color,count):
      vis[i]=True
      contains=False
      for j in g[i]:
          if(not vis[j]):
              x=yield dfs(j,g,vis,color,count)
              count[i]+=x
              if(x==0):
                  contains=True
      if(contains==False and color[i]==0):
          count[i]=1
      else:
          count[i]=0
      yield count[i]
  @bootstrap
  def dfs1(i,g,vis,count,g1):
      vis[i]=True
      ans=1
      for j in g[i]:
          if(not vis[j]):
              g1[i].append(j)
              x=yield dfs1(j,g,vis,count,g1)
              ans+=x
      count[i]=ans
      yield ans
  @bootstrap
  def dfs2(g1,i,vis):
      vis[i]=True
      for j in g1[i]:
          yield dfs2(g1,j,vis)
      yield 0
  class FenwickTree:
      def __init__(self, x):
          """transform list into BIT"""
          self.bit = x
          for i in range(len(x)):
              j = i | (i + 1)
              if j < len(x):
                  x[j] += x[i]
  
      def update(self, idx, x):
          """updates bit[idx] += x"""
          while idx < len(self.bit):
              self.bit[idx] += x
              idx |= idx + 1
  
      def query(self, end):
          """calc sum(bit[:end])"""
          x = 0
          while end:
              x += self.bit[end - 1]
              end &= end - 1
          return x
  
      def findkth(self, k):
          """Find largest idx such that sum(bit[:idx]) <= k"""
          idx = -1
          for d in reversed(range(len(self.bit).bit_length())):
              right_idx = idx + (1 << d)
              if right_idx < len(self.bit) and k >= self.bit[right_idx]:
                  idx = right_idx
                  k -= self.bit[idx]
          return idx + 1
  from collections import deque
  from math import ceil
  
  class DisjointSetUnion:
      def __init__(self, n):
          self.parent = list(range(n))
          self.size = [1] * n
          self.num_sets = n
  
      def find(self, a):
          acopy = a
          while a != self.parent[a]:
              a = self.parent[a]
          while acopy != a:
              self.parent[acopy], acopy = a, self.parent[acopy]
          return a
  
      def union(self, a, b):
          a, b = self.find(a), self.find(b)
          if a != b:
              if self.size[a] < self.size[b]:
                  a, b = b, a
  
              self.num_sets -= 1
              self.parent[b] = a
              self.size[a] += self.size[b]
  
      def set_size(self, a):
          return self.size[self.find(a)]
  
      def __len__(self):
          return self.num_sets
  
  
  class UnionFind:
      def __init__(self, n):
          self.parent = list(range(n))
  
      def find(self, a):
          acopy = a
          while a != self.parent[a]:
              a = self.parent[a]
          while acopy != a:
              self.parent[acopy], acopy = a, self.parent[acopy]
          return a
  
      def union(self, a, b):
          self.parent[self.find(b)] = self.find(a)
  
  
  def chk(a,x):
      n=len(a)
      daaan=[0]*n
      for i in range(n-1,1,-1):
          if(daaan[i]+a[i]<x):
              return False
          y=min(daaan[i]+a[i]-x,a[i])
          daaan[i-1]+=y//3
          daaan[i-2]+=2*(y//3)
      return (a[0]+daaan[0]>=x and a[1]+daaan[1]>=x)
  
  def main():
      val=10**9
      for _ in range(int(input())):
          n=int(input())
          h=list(map(int,input().split()))
          l=1
          h1=val
          ans=-1
          while(l<=h1):
              m=(l+h1)//2
              if(chk(list(h),m)):
                  ans=m
                  l=m+1
              else:
                  h1=m-1
          print(ans)
  # region fastio
  
  BUFSIZE = 8192
  
  
  class FastIO(IOBase):
      newlines = 0
  
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
  
      def read(self):
          while True:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
  
      def readline(self):
          while self.newlines == 0:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
  
      def flush(self):
          if self.writable:
              os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
  
  
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  def print(*args, **kwargs):
      """Prints the values to a stream, or to sys.stdout by default."""
      sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
      at_start = True
      for x in args:
          if not at_start:
              file.write(sep)
          file.write(str(x))
          at_start = False
      file.write(kwargs.pop("end", "\n"))
      if kwargs.pop("flush", False):
          file.flush()
  
  
  if sys.version_info[0] < 3:
      sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
  else:
      sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  
  # endregion
  
  if __name__ == "__main__":
      main()
  