#include <bits/stdc++.h>
using namespace std;
void _print(long long t) { cerr << t; }
void _print(int 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 << "]";
}
void showpq(priority_queue<long long> gq) {
  priority_queue<long long> g = gq;
  while (!g.empty()) {
    cerr << '\t' << g.top();
    g.pop();
  }
  cerr << '\n';
}
bool sortbysec(const vector<int> &a, const vector<int> &b) {
  return (a[1] < b[1]);
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
bool checker(vector<long long> ar, long long x, long long n) {
  vector<long long> m(n, 0);
  for (long long i = n - 1; i >= 0; i--) {
    if (ar[i] + m[i] < x) {
      return false;
      break;
    } else if (i >= 2) {
      int more = 0;
      if (x > m[i]) more = x - m[i];
      int d = (ar[i] - more) / 3;
      m[i - 1] += d;
      m[i - 2] += 2 * d;
    }
  }
  return true;
}
void solve() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> ar(n);
    long long start = 1e18, end = 0;
    for (long long i = 0; i < n; i++) {
      cin >> ar[i];
      start = min(start, ar[i]);
      end = max(end, ar[i]);
    }
    long long mid = (start + end) / 2;
    while (start < end - 1) {
      if (checker(ar, mid, n)) {
        start = mid;
      } else {
        end = mid;
      }
      mid = (end + start) / 2;
    };
    cout << start << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
