#include <stdio.h>
#include <stdlib.h>
#define DEBUG 1
#define NO 0
#define YES 1
int main ( int argc ,char *argv[] ) {
int t;
scanf("%d" , &t);
while ( t-- ) {
int n , i , answer = YES;
scanf("%d" , &n);
if ( n == 1 ) {
int x;
scanf("%d" , &x);
if ( x == 0 )
printf("YES\n");
else
printf("NO\n");
continue;
}
int count = 0;
scanf("%d" , &count);
for ( i = 1 ; i < n ; i++ ) {
int x;
scanf("%d" , &x);
x = x - count;
if ( x < 0 )
answer = NO;
count = x;
}
if ( count == 0 && answer == YES )
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
System Design for Beginners
A masterclass that helps early engineers and product managers become great at designing scalable systems.
132+ learners
Details →System Design Masterclass
A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.
1000+ learners
Details →Redis Internals
Learn internals of Redis by re-implementing some of the core features in Golang.
98+ learners
Details →