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: #include <bits/stdc++.h>
  using namespace std;
  void _print(long long t) { cerr << t; }
  void _print(int32_t t) { cerr << t; }
  void _print(string t) { cerr << t; }
  void _print(char t) { cerr << t; }
  void _print(long double t) { cerr << t; }
  void _print(double t) { cerr << t; }
  void _print(unsigned long long t) { cerr << t; }
  template <class T, class V>
  void _print(pair<T, V> p);
  template <class T>
  void _print(vector<T> v);
  template <class T>
  void _print(set<T> v);
  template <class T, class V>
  void _print(map<T, V> v);
  template <class T>
  void _print(multiset<T> v);
  template <class T, class V>
  void _print(pair<T, V> p) {
    cerr << "{";
    _print(p.first);
    cerr << ",";
    _print(p.second);
    cerr << "}";
  }
  template <class T>
  void _print(vector<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(set<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(multiset<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T, class V>
  void _print(map<T, V> v) {
    cerr << "[ ";
    for (auto i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  long long gcd(long long a, long long b) {
    if (b > a) {
      return gcd(b, a);
    }
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);
  }
  long long expo(long long a, long long b, long long m) {
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = (res * a) % m;
      a = (a * a) % m;
      b = b >> 1;
    }
    return res;
  }
  long long inv(long long a, long long b) { return expo(a, b - 2, b); }
  void swap(long long &x, long long &y) {
    long long temp = x;
    x = y;
    y = temp;
  }
  long long combination(long long n, long long r, long long m, long long *fact,
                        long long *ifact) {
    long long val1 = fact[n];
    long long val2 = ifact[n - r];
    long long val3 = ifact[r];
    return (((val1 * val2) % m) * val3) % m;
  }
  long long mod_add(long long a, long long b, long long m) {
    a = a % m;
    b = b % m;
    return (((a + b) % m) + m) % m;
  }
  long long mod_mul(long long a, long long b, long long m) {
    a = a % m;
    b = b % m;
    return (((a * b) % m) + m) % m;
  }
  long long mod_sub(long long a, long long b, long long m) {
    a = a % m;
    b = b % m;
    return (((a - b) % m) + m) % m;
  }
  long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = res * a;
      a = a * a;
      b >>= 1;
    }
    return res;
  }
  long long ceil_div(long long a, long long b) {
    return a % b == 0 ? a / b : a / b + 1;
  }
  long long fact[1001];
  long long invfact[1001];
  void factorial_calculation(long long n) {
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) {
      fact[i] = i * fact[i - 1] % 998244353;
    }
    for (long long i = 0; i <= n; i++) {
      invfact[i] = inv(fact[i], 998244353);
    }
  }
  vector<long long> sieve(long long n) {
    long long *arr = new long long[n + 1]();
    vector<long long> vect;
    for (long long i = 2; i <= n; i++)
      if (arr[i] == 0) {
        vect.push_back(i);
        for (long long j = 2 * i; j <= n; j += i) arr[j] = 1;
      }
    return vect;
  }
  bool ok(long long mid, long long h[], long long n) {
    vector<long long> add(n, 0);
    long long f = 0;
    for (long long i = n - 1; i >= 2; i--) {
      long long x = h[i] + add[i];
      ;
      ;
      ;
      if (x - mid < 0) {
        f = 1;
        break;
      } else {
        long long mn = min((x - mid) / 3, h[i] / 3);
        add[i - 1] += mn;
        add[i - 2] += 2 * mn;
        long long now = x - 3 * mn;
        if (now < mid) {
          break;
        }
      }
    }
    long long now1, now0;
    now1 = h[1] + add[1];
    now0 = h[0] + add[0];
    if (now1 < mid || now0 < mid) {
      f = 1;
    }
    if (f) {
      return false;
    } else
      return true;
  }
  void solve(long long tc) {
    long long n;
    cin >> n;
    long long h[n];
    for (long long(i) = (0); i < (n); i++) {
      cin >> h[i];
    }
    long long low = 0;
    long long high = 1000000001;
    long long ans = INT_MIN;
    while (low <= high) {
      long long mid = low + (high - low) / 2;
      ;
      bool isok = ok(mid, h, n);
      ;
      if (isok) {
        low = mid + 1;
        ans = max(ans, mid);
      } else {
        high = mid - 1;
      }
    }
    cout << ans << '\n';
  }
  int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ;
    long long t = 1;
    cin >> t;
    for (long long tc = 1; tc <= t; tc++) {
      solve(tc);
    }
  }
  