Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 342 ms):
#include<bits/stdc++.h>
using namespace std;
int main(){
        int t;
        cin>>t;
        for(int p=1;p<=t;p++){
            int n;
            cin>>n;
            int arr[n];
            for(int i=0;i<n;i++){
                cin>>arr[i];
            }
            int ct=0;
            for(int i=0;i<n-1;i++){
                if(arr[i]>arr[i+1]){
                    ct=-1;
                    break;
                }
                else{
                    int temp=min(arr[i],arr[i+1]);
                    arr[i]-=temp;
                    arr[i+1]-=temp;
                }
            }
            if(ct==0){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
            
            




        }
 
       
       
      
        




    }

Solution 2 (runtime: 109 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<b;i++)
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setiosflags(ios::fixed)<<setprecision(15);
const ll MOD = 1e9+7;


bool isPrime(ll n) {
    if (n <= 1) return false;
    if (n == 2) return true;
    if (n%2 == 0) return false;
    for (ll i = 3; i*i <= n; i+=2)
        if (n % i == 0)
            return false;
    return true;
 }

 vector<ll > Divisors(ll n){
    vector<ll>divisors;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            if (n / i == i)
                divisors.push_back(i);
            else {
                divisors.push_back(i);
                divisors.push_back(n/i);
            }
        }
    } return divisors;
 }

 vector<ll> primeFactors(ll n) {
    vector<ll>primefac;
    while (n % 2 == 0) {
        primefac.push_back(2);
        n = n/2;
    }
    for (ll i = 3; i*i <= n; i = i + 2) {
        while (n % i == 0) {
            primefac.push_back(i);
            n = n/i;
        }
    }
    if (n > 2)
        primefac.push_back(n);
    return primefac;
}



ll gcd(ll a, ll b) {
    while (b) {
        ll temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

int fib(int n){
    if(n<=1){
        return n;
    }else{
        return fib(n-1)+fib(n-2);
    }

}
int maxsub(int n,vector<int>vi){
    int best=0,sum=0;
    REP(i,0,n){
        sum=max(vi[i],vi[i]+sum);
        best=max(best,sum);
    }return best;


}

int check_bit(int x, int k) {
  return (x >> k) & 1;
}

int set_bit1(int x, int k) {
  return x | (1 << k);
}

int set_bit0(int x, int k) {
  return x & (~(1 << k));
}

int count_bits(int x) {
  int ans = 0;
  for (int k = 0; k < 32; k++) {
    if (check_bit(x, k)) {
      ans++;
    }
  }
  return ans;
}

bool power2(int x) {
  return count_bits(x) == 1;
}

int main() {
    fastio;
    int t=1;
    cin>>t;
    while(t--){
        bool test=true;
        int x;
        ll n;cin>>n;
        vector<ll> v(n);
        for(int i=0;i<n;i++){
            cin>>v[i];
        }
        vector<ll> a(n);

            for(int i=0;i<n-1;i++){
                x=min(v[i],v[i+1]);
                v[i]-=x;
                v[i+1]-=x;

            }
            a=v;
            sort(v.begin(),v.end());
            for(int i=0;i<n;i++){
                if(v[i]!=a[i]){
                   test=false;
                   break;
            }
            }if(test){
            cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }


} }