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

Solution 1 (runtime: 546 ms):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10,INF=0x3f3f3f3f;
map<int,int>mp; 
int qcp(int n,int m)/*n^m*/{
    int res=1;
    while(m){
        if(m&1) res=res*n;
        n=n*n;
        m>>=1;
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    int a[N]={0};
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=2;i<=n;i++)
    {
        if(a[i]<a[i-1]){cout<<"NO"<<endl;return;}
        else a[i]-=a[i-1];
    }
    cout<<"YES"<<endl;
}
signed main() 
{
	ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
  	int T=1;
  	cin>>T;
  	while(T--)
  	{
  		solve();
	}
    return 0;
}

Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>

using namespace std;

#define int long long

#define pb  push_back

#define mp  make_pair

#define INT_MAX                 INT64_MAX;

#define INT_MIN                 INT64_MIN;

#define IO_FAST                 ios_base::sync_with_stdio(false); cin.tie(NULL);

#define testcase                int t; cin >> t; while(t--)

#define inputvec(v1, n)         for(int i=0; i<n; i++) {int x; cin >> x; v1.pb(x);}

#define inputvecp(v1, n)        for(int i=0; i<n; i++) {int x, y; cin >> x >> y; v1.pb(mp(x,y));}

#define sort(v1)                sort(v1.begin(), v1.end())

#define reverse(v1)             reverse(v1.begin(), v1.end())

#define print(x)                cout << #x << endl;

#define deb(x)                  cout << #x << ' ' <<  '=' << ' ' << x << endl;

#define upperbound(v1, k)       upper_bound(v1.begin(), v1.end(), k)

#define lowerbound(v1, k)       lower_bound(v1.begin(), v1.end(), k)

#define tolower(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::tolower)

#define toupper(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::toupper)

#define auto1(v1)               for(auto &num1:v1) {cout << num1 << ' ';} cout << endl;

#define auto2(vp1)              for(auto &num1:vp1) {cout << num1.first << ' ' <<num1.second << endl;}

#define auto3(vv1)              for(auto &num1:vv1) {for(auto &num2:num1){cout << num2 <<' ';}cout<<endl;}

int gcd(int a,int b)            {if (b==0) return a; return gcd(b, a%b);} // take a=0;

int lcm(int a,int b)            {return a/gcd(a,b)*b;}  // take a = v[0];

const int N = 1e5+10;

const int mod = 1e9+7;

// freopen("in.txt", "r", stdin);

// freopen("out.txt", "w", stdout);

//======================================================================================================//

signed main()

{

    IO_FAST

    testcase

    {

        int n;

        cin >> n;



        vector<int> v1;

        inputvec(v1, n);

        

        bool flag = true;

        for(int i=1; i<n; i++)

        {

            if(i==1)

            {

                if(v1[0]>v1[1])

                {

                    flag = false;

                    break;

                }

                else

                {

                    v1[1] = v1[1]-v1[0];

                    v1[0] = 0;

                }

            }

            else

            {

                if(v1[i]>=v1[i-1])

                {

                    v1[i] = v1[i]-v1[i-1];

                    v1[i-1] = 0;

                }

                else

                {

                    flag = false;

                    break;

                }

                

            }

        }



        cout << ((flag)? "YES" : "NO") << endl;

    }

}