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.Arrays;
  import java.util.InputMismatchException;
  
  /**
   * Provide prove of correctness before implementation. Implementation can cost a lot of time.
   * Anti test that prove that it's wrong.
   * <p>
   * Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write more informative names to simulation
   * <p>
   * Will program ever exceed limit?
   * Try all approaches with prove of correctness if task is not obvious.
   * If you are given formula/rule: Try to play with it.
   * Analytic solution/Hardcoded solution/Constructive/Greedy/DP/Math/Brute force/Symmetric data
   * Number theory
   * Game theory (optimal play) that consider local and global strategy.
   */
  public class C {
  
      int n;
      long[] h = new long[200_001];
      long[] buffer = new long[200_001];
  
      private void solveOne() {
          n = nextInt();
          for (int i = 0; i < n; i++) {
              h[i] = nextLong();
          }
          //h = nextLongArr(n);
  
  
          long ans = 0;
          long border = 1_000_000_000_000L;
          while (border - ans > 1) {
              long mid = ans + (border - ans) / 2;
              if (pos(mid)) {
                  ans = mid;
              } else {
                  border = mid;
              }
          }
  
  
          //int n = h.length;
  
  
  //        long min = Long.MAX_VALUE;
  //        for (int i = 0; i < h.length; i++) {
  //            min = Math.min(min, h[i]);
  //        }
  
          System.out.println(ans);
  
      }
  
      boolean pos(long min) {
          //long[] h = Arrays.copyOf(h_immu, h_immu.length);
          //int n = h.length;
          for(int i = 0 ; i < n ; i ++ ) {
              buffer[i] = h[i];
          }
  
          for (int i = n - 1; i >= 2; i--) {
  
              //in case we go LTR we have only h_immu[i]
              //and we can give MORE than h_immu[i] - min, because we could get from the next
  
              //let's go RTL and give as much as possible
              if (buffer[i] < min) {
                  return false;
              }
              long weCanGet = (buffer[i] - min) / 3 * 3;
              weCanGet = Math.min(weCanGet, h[i] / 3 * 3);
  //            weCanGet = Math.min(weCanGet, h_immu[i]);
  //            if(weCanGet % 3 != 0) {
  //                throw new RuntimeException();
  //            }
  
              buffer[i] -= weCanGet;
              buffer[i - 1] += weCanGet / 3;
              buffer[i - 2] += weCanGet / 3 * 2;
          }
  
          return buffer[0] >= min && buffer[1] >= min;
      }
  
      private void solve() {
          int t = System.in.readInt();
          for (int tt = 0; tt < t; tt++) {
              solveOne();
          }
      }
  
      class AssertionRuntimeException extends RuntimeException {
  
          AssertionRuntimeException(Object expected,
                                    Object actual, Object... input) {
              super("expected = " + expected + ",\n actual = " + actual + ",\n " + Arrays.deepToString(input));
          }
      }
  
      private int nextInt() {
          return System.in.readInt();
      }
  
      private long nextLong() {
          return System.in.readLong();
      }
  
      private String nextString() {
          return System.in.readString();
      }
  
      private int[] nextIntArr(int n) {
          return System.in.readIntArray(n);
      }
  
      private long[] nextLongArr(int n) {
          return System.in.readLongArray(n);
      }
  
  
      public static void main(String[] args) {
          new C().run();
      }
  
      static class System {
          private static FastInputStream in;
          private static FastWriterNoRangeChecks out;
      }
  
      private void run() {
          System.in = new FastInputStream(java.lang.System.in);
          System.out = new FastWriterNoRangeChecks(java.lang.System.out);
          solve();
          System.out.flush();
      }
  
      
  
      private static class FastInputStream {
          private boolean finished = false;
  
          private InputStream stream;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
          private SpaceCharFilter filter;
  
          public FastInputStream(InputStream stream) {
              this.stream = stream;
          }
  
          public double[] readDoubleArray(int size) {
              double[] array = new double[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readDouble();
              }
              return array;
          }
  
          public String[] readStringArray(int size) {
              String[] array = new String[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readString();
              }
              return array;
          }
  
          public char[] readCharArray(int size) {
              char[] array = new char[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readCharacter();
              }
              return array;
          }
  
          public void readIntArrays(int[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readInt();
                  }
              }
          }
  
          public void readLongArrays(long[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readLong();
                  }
              }
          }
  
          public void readDoubleArrays(double[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readDouble();
                  }
              }
          }
  
          public char[][] readTable(int rowCount, int columnCount) {
              char[][] table = new char[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readCharArray(columnCount);
              }
              return table;
          }
  
          public int[][] readIntTable(int rowCount, int columnCount) {
              int[][] table = new int[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = readIntArray(columnCount);
              }
              return table;
          }
  
          public double[][] readDoubleTable(int rowCount, int columnCount) {
              double[][] table = new double[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readDoubleArray(columnCount);
              }
              return table;
          }
  
          public long[][] readLongTable(int rowCount, int columnCount) {
              long[][] table = new long[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = readLongArray(columnCount);
              }
              return table;
          }
  
          public String[][] readStringTable(int rowCount, int columnCount) {
              String[][] table = new String[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readStringArray(columnCount);
              }
              return table;
          }
  
          public String readText() {
              StringBuilder result = new StringBuilder();
              while (true) {
                  int character = read();
                  if (character == '\r') {
                      continue;
                  }
                  if (character == -1) {
                      break;
                  }
                  result.append((char) character);
              }
              return result.toString();
          }
  
          public void readStringArrays(String[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readString();
                  }
              }
          }
  
          public long[] readLongArray(int size) {
              long[] array = new long[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readLong();
              }
              return array;
          }
  
          public int[] readIntArray(int size) {
              int[] array = new int[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readInt();
              }
              return array;
          }
  
          public int read() {
              if (numChars == -1) {
                  throw new InputMismatchException();
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar++];
          }
  
          public int peek() {
              if (numChars == -1) {
                  return -1;
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      return -1;
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar];
          }
  
          public int peekNonWhitespace() {
              while (isWhitespace(peek())) {
                  read();
              }
              return peek();
          }
  
          public int readInt() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public long readLong() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public String readString() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              StringBuilder res = new StringBuilder();
              do {
                  if (Character.isValidCodePoint(c)) {
                      res.appendCodePoint(c);
                  }
                  c = read();
              } while (!isSpaceChar(c));
              return res.toString();
          }
  
          public boolean isSpaceChar(int c) {
              if (filter != null) {
                  return filter.isSpaceChar(c);
              }
              return isWhitespace(c);
          }
  
          public static boolean isWhitespace(int c) {
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
          private String readLine0() {
              StringBuilder buf = new StringBuilder();
              int c = read();
              while (c != '\n' && c != -1) {
                  if (c != '\r') {
                      buf.appendCodePoint(c);
                  }
                  c = read();
              }
              return buf.toString();
          }
  
          public String readLine() {
              String s = readLine0();
              while (s.trim().length() == 0) {
                  s = readLine0();
              }
              return s;
          }
  
          public String readLine(boolean ignoreEmptyLines) {
              if (ignoreEmptyLines) {
                  return readLine();
              } else {
                  return readLine0();
              }
          }
  
          public char readCharacter() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              return (char) c;
          }
  
          public double readDouble() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              double res = 0;
              while (!isSpaceChar(c) && c != '.') {
                  if (c == 'e' || c == 'E') {
                      return res * Math.pow(10, readInt());
                  }
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              if (c == '.') {
                  c = read();
                  double m = 1;
                  while (!isSpaceChar(c)) {
                      if (c == 'e' || c == 'E') {
                          return res * Math.pow(10, readInt());
                      }
                      if (c < '0' || c > '9') {
                          throw new InputMismatchException();
                      }
                      m /= 10;
                      res += (c - '0') * m;
                      c = read();
                  }
              }
              return res * sgn;
          }
  
          public boolean isExhausted() {
              int value;
              while (isSpaceChar(value = peek()) && value != -1) {
                  read();
              }
              return value == -1;
          }
  
          public String next() {
              return readString();
          }
  
          public SpaceCharFilter getFilter() {
              return filter;
          }
  
          public void setFilter(SpaceCharFilter filter) {
              this.filter = filter;
          }
  
          public interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
          }
      }
  
  
      public static class FastWriterNoRangeChecks {
          private static final int BUF_SIZE = 2_000_000;//50_000_000 100_000_000
          private final byte[] buf = new byte[BUF_SIZE];
          private final OutputStream out;
          private int ptr = 0;
  
          private FastWriterNoRangeChecks() {
              this.out = java.lang.System.out;
          }
  
          public FastWriterNoRangeChecks(OutputStream os) {
              this.out = os;
          }
  
          public FastWriterNoRangeChecks(String path) {
              try {
                  this.out = new FileOutputStream(path);
              } catch (FileNotFoundException e) {
                  throw new RuntimeException("FastWriter");
              }
          }
  
          public FastWriterNoRangeChecks write(byte b) {
              buf[ptr++] = b;
              return this;
          }
  
          public FastWriterNoRangeChecks write(char c) {
              return write((byte) c);
          }
  
          public FastWriterNoRangeChecks write(char[] s) {
              for (char c : s) {
                  buf[ptr++] = (byte) c;
              }
              return this;
          }
  
          public FastWriterNoRangeChecks write(String s) {
              s.chars().forEach(c -> {
                  buf[ptr++] = (byte) c;
              });
              return this;
          }
  
          //can be optimized
          public FastWriterNoRangeChecks print0(char[] s) {
  
              for (int i = 0, n = s.length; i < n; i++) {
                  buf[ptr++] = (byte) s[i];
              }
  
              return this;
          }
  
          //can be optimized
          public FastWriterNoRangeChecks print0(String s) {
  
              for (int i = 0, n = s.length(); i < n; i++) {
                  buf[ptr++] = (byte) s.charAt(i);
              }
  
              return this;
          }
  
          private static int countDigits(int l) {
              if (l >= 1000000000) return 10;
              if (l >= 100000000) return 9;
              if (l >= 10000000) return 8;
              if (l >= 1000000) return 7;
              if (l >= 100000) return 6;
              if (l >= 10000) return 5;
              if (l >= 1000) return 4;
              if (l >= 100) return 3;
              if (l >= 10) return 2;
              return 1;
          }
  
          public FastWriterNoRangeChecks write(int x) {
              if (x == Integer.MIN_VALUE) {
                  return write((long) x);
              }
              //if (ptr + 12 >= BUF_SIZE) innerflush();
              if (x < 0) {
                  write((byte) '-');
                  x = -x;
              }
              int d = countDigits(x);
              for (int i = ptr + d - 1; i >= ptr; i--) {
                  buf[i] = (byte) ('0' + x % 10);
                  x /= 10;
              }
              ptr += d;
              return this;
          }
  
          private static int countDigits(long l) {
              if (l >= 1000000000000000000L) return 19;
              if (l >= 100000000000000000L) return 18;
              if (l >= 10000000000000000L) return 17;
              if (l >= 1000000000000000L) return 16;
              if (l >= 100000000000000L) return 15;
              if (l >= 10000000000000L) return 14;
              if (l >= 1000000000000L) return 13;
              if (l >= 100000000000L) return 12;
              if (l >= 10000000000L) return 11;
              if (l >= 1000000000L) return 10;
              if (l >= 100000000L) return 9;
              if (l >= 10000000L) return 8;
              if (l >= 1000000L) return 7;
              if (l >= 100000L) return 6;
              if (l >= 10000L) return 5;
              if (l >= 1000L) return 4;
              if (l >= 100L) return 3;
              if (l >= 10L) return 2;
              return 1;
          }
  
          public FastWriterNoRangeChecks write(long x) {
              if (x == Long.MIN_VALUE) {
                  return write("" + x);
              }
  //            if (ptr + 21 >= BUF_SIZE) innerflush();
              if (x < 0) {
                  write((byte) '-');
                  x = -x;
              }
              int d = countDigits(x);
              for (int i = ptr + d - 1; i >= ptr; i--) {
                  buf[i] = (byte) ('0' + x % 10);
                  x /= 10;
              }
              ptr += d;
              return this;
          }
  
          public FastWriterNoRangeChecks write(double x, int precision) {
              if (x < 0) {
                  write('-');
                  x = -x;
              }
              x += Math.pow(10, -precision) / 2;
              //		if(x < 0){ x = 0; }
              write((long) x).write(".");
              x -= (long) x;
              for (int i = 0; i < precision; i++) {
                  x *= 10;
                  write((char) ('0' + (int) x));
                  x -= (int) x;
              }
              return this;
          }
  
          public FastWriterNoRangeChecks writeln(char c) {
              return write(c).writeln();
          }
  
          public FastWriterNoRangeChecks writeln(int x) {
              return write(x).writeln();
          }
  
          public FastWriterNoRangeChecks writeln(long x) {
              return write(x).writeln();
          }
  
          public FastWriterNoRangeChecks writeln(double x, int precision) {
              return write(x, precision).writeln();
          }
  
          public FastWriterNoRangeChecks write(int... xs) {
              boolean first = true;
              for (int x : xs) {
                  if (!first) write(' ');
                  first = false;
                  write(x);
              }
              return this;
          }
  
          public FastWriterNoRangeChecks write(long... xs) {
              boolean first = true;
              for (long x : xs) {
                  if (!first) write(' ');
                  first = false;
                  write(x);
              }
              return this;
          }
  
          public FastWriterNoRangeChecks writeln() {
              return write((byte) '\n');
          }
  
          public FastWriterNoRangeChecks writeln(int... xs) {
              return write(xs).writeln();
          }
  
          public FastWriterNoRangeChecks writeln(long... xs) {
              return write(xs).writeln();
          }
  
          public FastWriterNoRangeChecks writeln(char[] line) {
              return write(line).writeln();
          }
  
          public FastWriterNoRangeChecks writeln(char[]... map) {
              for (char[] line : map) write(line).writeln();
              return this;
          }
  
          public FastWriterNoRangeChecks writeln(String s) {
              return write(s).writeln();
          }
  
          private void innerflush() {
              try {
                  out.write(buf, 0, ptr);
                  ptr = 0;
              } catch (IOException e) {
                  throw new RuntimeException("innerflush");
              }
          }
  
          public void flush() {
              innerflush();
              try {
                  out.flush();
              } catch (IOException e) {
                  throw new RuntimeException("flush");
              }
          }
  
          public FastWriterNoRangeChecks print(byte b) {
              return write(b);
          }
  
          public FastWriterNoRangeChecks print(char c) {
              return write(c);
          }
  
          public FastWriterNoRangeChecks print(char[] s) {
              return write(s);
          }
  
          public FastWriterNoRangeChecks print(String s) {
              return write(s);
          }
  
          public FastWriterNoRangeChecks print(int x) {
              return write(x);
          }
  
          public FastWriterNoRangeChecks print(long x) {
              return write(x);
          }
  
          public FastWriterNoRangeChecks print(double x, int precision) {
              return write(x, precision);
          }
  
          public FastWriterNoRangeChecks println(char c) {
              return writeln(c);
          }
  
          public FastWriterNoRangeChecks println(int x) {
              return writeln(x);
          }
  
          public FastWriterNoRangeChecks println(long x) {
              return writeln(x);
          }
  
          public FastWriterNoRangeChecks println(double x, int precision) {
              return writeln(x, precision);
          }
  
          public FastWriterNoRangeChecks print(int... xs) {
              return write(xs);
          }
  
          public FastWriterNoRangeChecks print(long... xs) {
              return write(xs);
          }
  
          public FastWriterNoRangeChecks println(int... xs) {
              return writeln(xs);
          }
  
          public FastWriterNoRangeChecks println(long... xs) {
              return writeln(xs);
          }
  
          public FastWriterNoRangeChecks println(char[] line) {
              return writeln(line);
          }
  
          public FastWriterNoRangeChecks println(char[]... map) {
              return writeln(map);
          }
  
          public FastWriterNoRangeChecks println(String s) {
              return writeln(s);
          }
  
          public FastWriterNoRangeChecks println() {
              return writeln();
          }
      }
  }