#include <bits/stdc++.h>
using namespace std;
int a[30123], prefmn[30123], suffmn[30123];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    string ans = "YES";
    int take = a[0];
    a[0] = 0;
    for (int i = 1; i < n; i++) {
      if (a[i - 1] > 0) {
        take = min(take, max(0, a[i] - a[i - 1]));
      } else {
        take = min(take, a[i]);
      }
      a[i] -= take;
    }
    suffmn[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) suffmn[i] = min(suffmn[i + 1], a[i]);
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == 0) break;
      a[i] -= suffmn[i];
    }
    for (int i = 0; i < n; i++) {
      if (a[i] != 0) {
        ans = "NO";
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
