Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
 
#define ln              "\n" // no flush, oppos of endl
#define _flush          endl
#define stop_sync       ios::sync_with_stdio(false) // not to use c-style io
#define untie_ios       cin.tie(nullptr) // no flush
#define ll             long long int
#define vi              vector<int>
#define vii             vector<ll>
#define vch             vector<char>
#define double          long double
#define vss             vector<string>
#define vpp(T1, T2)     vector<pair<T1, T2>>
#define pq              priority_queue // high prec.
#define pqq(T)          priority_queue<T, vector<T>, greater<T>>            
#define pb              push_back
#define ppb             pop_back
#define mp              make_pair
#define Fi(p)           get<0>(p)
#define Sc(p)           get<1>(p)
#define sz(x)           int ((x).size())
#define all(x)          (x).begin(), (x).end()
#define bin_sc(a, x)    binary_search(all(a), x)
#define lbd(a, x)       lower_bound(all(a), x) // an iter.
#define ubd(a, x)       upper_bound(all(a), x) // an iter.
#define eq_seg(a, x)    equal_range(all(a), x) // a pair of lb, ub
#define FIXED(x)        cout << fixed << setprecision(x)
#define _print(x)       cout << (#x) << ": " << (x) << ln
#define uceil(a, b)     ((a + b - 1) / (b))
#define ff first
#define ss second

 
#include <iostream>
#include <vector>
#include <algorithm>
ll factorial(ll n) 
{ 
    // single line to find factorial 
    return (n==1 || n==0) ? 1: n * factorial(n - 1);  
} 
  const int N=1e5+10;
  vector<ll>g[N],g1[N];
  void dfs(ll v,ll p){
    for(auto child:g[v]){

      if(child==p)continue;

      dfs(child,v);
    }
    
  }
  
  //vector<ll>path(ll v){
  //  vector<ll>ans;
  //  while(v!=-1){ 
   //   ans.pb(v);
   //   v=par[v];
  //  }
  //  reverse(ans.begin(),ans.end());
   // return ans;

 // }
    


 int main(){
        ll t;
        cin>>t;
        while(t--){
          ll n;
          cin>>n;
          ll a[n];
          for(ll i=0;i<n;i++){
            cin>>a[i];
          }
          ll cnt=0;
          ll x=a[1]-a[0];
          if(x>0)cnt++;
          if(x>0){
          for(ll i=2;i<n;i++){
            if(a[i]-x>0){
              x=a[i]-x;
              cnt++;
            }
          }
          }
          if(cnt==n-1){
            cout<<"YES"<<endl;
          }
          else{
            cout<<"NO"<<endl;
          }

        
        
      }
    }
          
          

        
      

       

        

    


Submission (verdict: Wrong answer on test 10):
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
 
#define ln              "\n" // no flush, oppos of endl
#define _flush          endl
#define stop_sync       ios::sync_with_stdio(false) // not to use c-style io
#define untie_ios       cin.tie(nullptr) // no flush
#define ll             long long int
#define vi              vector<int>
#define vii             vector<ll>
#define vch             vector<char>
#define double          long double
#define vss             vector<string>
#define vpp(T1, T2)     vector<pair<T1, T2>>
#define pq              priority_queue // high prec.
#define pqq(T)          priority_queue<T, vector<T>, greater<T>>            
#define pb              push_back
#define ppb             pop_back
#define mp              make_pair
#define Fi(p)           get<0>(p)
#define Sc(p)           get<1>(p)
#define sz(x)           int ((x).size())
#define all(x)          (x).begin(), (x).end()
#define bin_sc(a, x)    binary_search(all(a), x)
#define lbd(a, x)       lower_bound(all(a), x) // an iter.
#define ubd(a, x)       upper_bound(all(a), x) // an iter.
#define eq_seg(a, x)    equal_range(all(a), x) // a pair of lb, ub
#define FIXED(x)        cout << fixed << setprecision(x)
#define _print(x)       cout << (#x) << ": " << (x) << ln
#define uceil(a, b)     ((a + b - 1) / (b))
#define ff first
#define ss second

 
#include <iostream>
#include <vector>
#include <algorithm>
ll factorial(ll n) 
{ 
    // single line to find factorial 
    return (n==1 || n==0) ? 1: n * factorial(n - 1);  
} 
  const int N=1e5+10;
  vector<ll>g[N],g1[N];
  void dfs(ll v,ll p){
    for(auto child:g[v]){

      if(child==p)continue;

      dfs(child,v);
    }
    
  }
  
  //vector<ll>path(ll v){
  //  vector<ll>ans;
  //  while(v!=-1){ 
   //   ans.pb(v);
   //   v=par[v];
  //  }
  //  reverse(ans.begin(),ans.end());
   // return ans;

 // }
    


 int main(){
        ll t;
        cin>>t;
        while(t--){
          ll n;
          cin>>n;
          ll a[n];
          for(ll i=0;i<n;i++){
            cin>>a[i];
          }
          ll cnt=0;
          ll x=a[1]-a[0];
          if(x>0)cnt++;
          if(x>0){
          for(ll i=2;i<n;i++){
            if(a[i]-x>=0){
              x=(a[i]-x);
              cnt++;
            }
          }
          }
          if(cnt==n-1){
            cout<<"YES"<<endl;
          }
          else{
            cout<<"NO"<<endl;
          }

        
        
      }
    }