#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long N = 2e5 + 4;
const long long mod = 1e9 + 7;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (auto &i : a) {
    cin >> i;
  }
  bool ok = 1;
  long long leave = 0, mn = a[0];
  a[0] = 0;
  for (long long i = 1; i < n - 1; i++) {
    if (a[i] <= leave) {
      break;
    }
    mn = min(mn, a[i] - leave);
    a[i] -= mn;
    leave = max(leave, a[i]);
  }
  mn = a[n - 1];
  a[n - 1] = 0;
  for (long long i = n - 2; i > 0; i--) {
    if (a[i] > mn) {
      break;
    } else {
      mn = a[i];
      a[i] = 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (a[i]) ok = 0;
  }
  if (ok) {
    cout << "YES" << endl;
    return;
  }
  cout << "NO" << endl;
}
int32_t main() {
  long long tt;
  cin >> tt;
  for (long long t = 1; t <= tt; t++) {
    solve();
  }
}
