#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000007;
const long long INFL = 1000000000000000007;
const long double INFS = 0.00000001;
const long long MOD = 1000000007;
const long double PI = 3.14159265;
const int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int dir2[8][2] = {{1, 1},  {1, 0},  {1, -1}, {0, 1},
                        {0, -1}, {-1, 1}, {-1, 0}, {-1, -1}};
int n;
int a[30001];
void wk() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  int Min = INF;
  for (i = 1; i <= n; i++) {
    Min = min(Min, max(a[i] - a[i - 1], 0));
    a[i] -= Min;
  }
  Min = INF;
  for (i = n; i >= 1; i--) {
    Min = min(Min, a[i]);
    a[i] -= Min;
    if (a[i] > 0) break;
  }
  for (i = 1; i <= n; i++)
    if (a[i]) {
      cout << "NO" << endl;
      return;
    }
  cout << "YES" << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  int i;
  cin >> t;
  for (i = 1; i <= t; i++) wk();
  return 0;
}
