var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var arr=readline().split(" ").map(function(x){return parseInt(x);});

    var prefix=0;
    var suffix=0;
    var no=false;
    for(var i=0;i<arr.length;i++){
        prefix+=arr[i];
        if(prefix<=0){print("NO");no=true;break;}

        suffix+=arr[arr.length-1-i];
        if(suffix<=0){print("NO");no=true;break;}
    }
    if(!no){print("YES");}
}//num runs

'use strict';

var readline = require('readline');

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function isFunction(x) {
    return typeof x === 'function';
}
//# sourceMappingURL=isFunction.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var _enable_super_gross_mode_that_will_cause_bad_things = false;
var config = {
    Promise: undefined,
    set useDeprecatedSynchronousErrorHandling(value) {
        if (value) {
            var error = /*@__PURE__*/ new Error();
            /*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
        }
        _enable_super_gross_mode_that_will_cause_bad_things = value;
    },
    get useDeprecatedSynchronousErrorHandling() {
        return _enable_super_gross_mode_that_will_cause_bad_things;
    },
};
//# sourceMappingURL=config.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function hostReportError(err) {
    setTimeout(function () { throw err; }, 0);
}
//# sourceMappingURL=hostReportError.js.map

/** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
var empty = {
    closed: true,
    next: function (value) { },
    error: function (err) {
        if (config.useDeprecatedSynchronousErrorHandling) {
            throw err;
        }
        else {
            hostReportError(err);
        }
    },
    complete: function () { }
};
//# sourceMappingURL=Observer.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
//# sourceMappingURL=isArray.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function isObject(x) {
    return x !== null && typeof x === 'object';
}
//# sourceMappingURL=isObject.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
    function UnsubscriptionErrorImpl(errors) {
        Error.call(this);
        this.message = errors ?
            errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n  ') : '';
        this.name = 'UnsubscriptionError';
        this.errors = errors;
        return this;
    }
    UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
    return UnsubscriptionErrorImpl;
})();
var UnsubscriptionError = UnsubscriptionErrorImpl;
//# sourceMappingURL=UnsubscriptionError.js.map

/** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
var Subscription = /*@__PURE__*/ (function () {
    function Subscription(unsubscribe) {
        this.closed = false;
        this._parentOrParents = null;
        this._subscriptions = null;
        if (unsubscribe) {
            this._unsubscribe = unsubscribe;
        }
    }
    Subscription.prototype.unsubscribe = function () {
        var errors;
        if (this.closed) {
            return;
        }
        var _a = this, _parentOrParents = _a._parentOrParents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
        this.closed = true;
        this._parentOrParents = null;
        this._subscriptions = null;
        if (_parentOrParents instanceof Subscription) {
            _parentOrParents.remove(this);
        }
        else if (_parentOrParents !== null) {
            for (var index = 0; index < _parentOrParents.length; ++index) {
                var parent_1 = _parentOrParents[index];
                parent_1.remove(this);
            }
        }
        if (isFunction(_unsubscribe)) {
            try {
                _unsubscribe.call(this);
            }
            catch (e) {
                errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
            }
        }
        if (isArray(_subscriptions)) {
            var index = -1;
            var len = _subscriptions.length;
            while (++index < len) {
                var sub = _subscriptions[index];
                if (isObject(sub)) {
                    try {
                        sub.unsubscribe();
                    }
                    catch (e) {
                        errors = errors || [];
                        if (e instanceof UnsubscriptionError) {
                            errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
                        }
                        else {
                            errors.push(e);
                        }
                    }
                }
            }
        }
        if (errors) {
            throw new UnsubscriptionError(errors);
        }
    };
    Subscription.prototype.add = function (teardown) {
        var subscription = teardown;
        if (!teardown) {
            return Subscription.EMPTY;
        }
        switch (typeof teardown) {
            case 'function':
                subscription = new Subscription(teardown);
            case 'object':
                if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
                    return subscription;
                }
                else if (this.closed) {
                    subscription.unsubscribe();
                    return subscription;
                }
                else if (!(subscription instanceof Subscription)) {
                    var tmp = subscription;
                    subscription = new Subscription();
                    subscription._subscriptions = [tmp];
                }
                break;
            default: {
                throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
            }
        }
        var _parentOrParents = subscription._parentOrParents;
        if (_parentOrParents === null) {
            subscription._parentOrParents = this;
        }
        else if (_parentOrParents instanceof Subscription) {
            if (_parentOrParents === this) {
                return subscription;
            }
            subscription._parentOrParents = [_parentOrParents, this];
        }
        else if (_parentOrParents.indexOf(this) === -1) {
            _parentOrParents.push(this);
        }
        else {
            return subscription;
        }
        var subscriptions = this._subscriptions;
        if (subscriptions === null) {
            this._subscriptions = [subscription];
        }
        else {
            subscriptions.push(subscription);
        }
        return subscription;
    };
    Subscription.prototype.remove = function (subscription) {
        var subscriptions = this._subscriptions;
        if (subscriptions) {
            var subscriptionIndex = subscriptions.indexOf(subscription);
            if (subscriptionIndex !== -1) {
                subscriptions.splice(subscriptionIndex, 1);
            }
        }
    };
    Subscription.EMPTY = (function (empty) {
        empty.closed = true;
        return empty;
    }(new Subscription()));
    return Subscription;
}());
function flattenUnsubscriptionErrors(errors) {
    return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
}
//# sourceMappingURL=Subscription.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var rxSubscriber = /*@__PURE__*/ (function () {
    return typeof Symbol === 'function'
        ? /*@__PURE__*/ Symbol('rxSubscriber')
        : '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
})();
//# sourceMappingURL=rxSubscriber.js.map

/** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
var Subscriber = /*@__PURE__*/ (function (_super) {
    __extends(Subscriber, _super);
    function Subscriber(destinationOrNext, error, complete) {
        var _this = _super.call(this) || this;
        _this.syncErrorValue = null;
        _this.syncErrorThrown = false;
        _this.syncErrorThrowable = false;
        _this.isStopped = false;
        switch (arguments.length) {
            case 0:
                _this.destination = empty;
                break;
            case 1:
                if (!destinationOrNext) {
                    _this.destination = empty;
                    break;
                }
                if (typeof destinationOrNext === 'object') {
                    if (destinationOrNext instanceof Subscriber) {
                        _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
                        _this.destination = destinationOrNext;
                        destinationOrNext.add(_this);
                    }
                    else {
                        _this.syncErrorThrowable = true;
                        _this.destination = new SafeSubscriber(_this, destinationOrNext);
                    }
                    break;
                }
            default:
                _this.syncErrorThrowable = true;
                _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
                break;
        }
        return _this;
    }
    Subscriber.prototype[rxSubscriber] = function () { return this; };
    Subscriber.create = function (next, error, complete) {
        var subscriber = new Subscriber(next, error, complete);
        subscriber.syncErrorThrowable = false;
        return subscriber;
    };
    Subscriber.prototype.next = function (value) {
        if (!this.isStopped) {
            this._next(value);
        }
    };
    Subscriber.prototype.error = function (err) {
        if (!this.isStopped) {
            this.isStopped = true;
            this._error(err);
        }
    };
    Subscriber.prototype.complete = function () {
        if (!this.isStopped) {
            this.isStopped = true;
            this._complete();
        }
    };
    Subscriber.prototype.unsubscribe = function () {
        if (this.closed) {
            return;
        }
        this.isStopped = true;
        _super.prototype.unsubscribe.call(this);
    };
    Subscriber.prototype._next = function (value) {
        this.destination.next(value);
    };
    Subscriber.prototype._error = function (err) {
        this.destination.error(err);
        this.unsubscribe();
    };
    Subscriber.prototype._complete = function () {
        this.destination.complete();
        this.unsubscribe();
    };
    Subscriber.prototype._unsubscribeAndRecycle = function () {
        var _parentOrParents = this._parentOrParents;
        this._parentOrParents = null;
        this.unsubscribe();
        this.closed = false;
        this.isStopped = false;
        this._parentOrParents = _parentOrParents;
        return this;
    };
    return Subscriber;
}(Subscription));
var SafeSubscriber = /*@__PURE__*/ (function (_super) {
    __extends(SafeSubscriber, _super);
    function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
        var _this = _super.call(this) || this;
        _this._parentSubscriber = _parentSubscriber;
        var next;
        var context = _this;
        if (isFunction(observerOrNext)) {
            next = observerOrNext;
        }
        else if (observerOrNext) {
            next = observerOrNext.next;
            error = observerOrNext.error;
            complete = observerOrNext.complete;
            if (observerOrNext !== empty) {
                context = Object.create(observerOrNext);
                if (isFunction(context.unsubscribe)) {
                    _this.add(context.unsubscribe.bind(context));
                }
                context.unsubscribe = _this.unsubscribe.bind(_this);
            }
        }
        _this._context = context;
        _this._next = next;
        _this._error = error;
        _this._complete = complete;
        return _this;
    }
    SafeSubscriber.prototype.next = function (value) {
        if (!this.isStopped && this._next) {
            var _parentSubscriber = this._parentSubscriber;
            if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                this.__tryOrUnsub(this._next, value);
            }
            else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.error = function (err) {
        if (!this.isStopped) {
            var _parentSubscriber = this._parentSubscriber;
            var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
            if (this._error) {
                if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                    this.__tryOrUnsub(this._error, err);
                    this.unsubscribe();
                }
                else {
                    this.__tryOrSetError(_parentSubscriber, this._error, err);
                    this.unsubscribe();
                }
            }
            else if (!_parentSubscriber.syncErrorThrowable) {
                this.unsubscribe();
                if (useDeprecatedSynchronousErrorHandling) {
                    throw err;
                }
                hostReportError(err);
            }
            else {
                if (useDeprecatedSynchronousErrorHandling) {
                    _parentSubscriber.syncErrorValue = err;
                    _parentSubscriber.syncErrorThrown = true;
                }
                else {
                    hostReportError(err);
                }
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.complete = function () {
        var _this = this;
        if (!this.isStopped) {
            var _parentSubscriber = this._parentSubscriber;
            if (this._complete) {
                var wrappedComplete = function () { return _this._complete.call(_this._context); };
                if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                    this.__tryOrUnsub(wrappedComplete);
                    this.unsubscribe();
                }
                else {
                    this.__tryOrSetError(_parentSubscriber, wrappedComplete);
                    this.unsubscribe();
                }
            }
            else {
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
        try {
            fn.call(this._context, value);
        }
        catch (err) {
            this.unsubscribe();
            if (config.useDeprecatedSynchronousErrorHandling) {
                throw err;
            }
            else {
                hostReportError(err);
            }
        }
    };
    SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
        if (!config.useDeprecatedSynchronousErrorHandling) {
            throw new Error('bad call');
        }
        try {
            fn.call(this._context, value);
        }
        catch (err) {
            if (config.useDeprecatedSynchronousErrorHandling) {
                parent.syncErrorValue = err;
                parent.syncErrorThrown = true;
                return true;
            }
            else {
                hostReportError(err);
                return true;
            }
        }
        return false;
    };
    SafeSubscriber.prototype._unsubscribe = function () {
        var _parentSubscriber = this._parentSubscriber;
        this._context = null;
        this._parentSubscriber = null;
        _parentSubscriber.unsubscribe();
    };
    return SafeSubscriber;
}(Subscriber));
//# sourceMappingURL=Subscriber.js.map

/** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
function canReportError(observer) {
    while (observer) {
        var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
        if (closed_1 || isStopped) {
            return false;
        }
        else if (destination && destination instanceof Subscriber) {
            observer = destination;
        }
        else {
            observer = null;
        }
    }
    return true;
}
//# sourceMappingURL=canReportError.js.map

/** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
function toSubscriber(nextOrObserver, error, complete) {
    if (nextOrObserver) {
        if (nextOrObserver instanceof Subscriber) {
            return nextOrObserver;
        }
        if (nextOrObserver[rxSubscriber]) {
            return nextOrObserver[rxSubscriber]();
        }
    }
    if (!nextOrObserver && !error && !complete) {
        return new Subscriber(empty);
    }
    return new Subscriber(nextOrObserver, error, complete);
}
//# sourceMappingURL=toSubscriber.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
//# sourceMappingURL=observable.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function noop() { }
//# sourceMappingURL=noop.js.map

/** PURE_IMPORTS_START _noop PURE_IMPORTS_END */
function pipeFromArray(fns) {
    if (!fns) {
        return noop;
    }
    if (fns.length === 1) {
        return fns[0];
    }
    return function piped(input) {
        return fns.reduce(function (prev, fn) { return fn(prev); }, input);
    };
}
//# sourceMappingURL=pipe.js.map

/** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
var Observable = /*@__PURE__*/ (function () {
    function Observable(subscribe) {
        this._isScalar = false;
        if (subscribe) {
            this._subscribe = subscribe;
        }
    }
    Observable.prototype.lift = function (operator) {
        var observable = new Observable();
        observable.source = this;
        observable.operator = operator;
        return observable;
    };
    Observable.prototype.subscribe = function (observerOrNext, error, complete) {
        var operator = this.operator;
        var sink = toSubscriber(observerOrNext, error, complete);
        if (operator) {
            sink.add(operator.call(sink, this.source));
        }
        else {
            sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
                this._subscribe(sink) :
                this._trySubscribe(sink));
        }
        if (config.useDeprecatedSynchronousErrorHandling) {
            if (sink.syncErrorThrowable) {
                sink.syncErrorThrowable = false;
                if (sink.syncErrorThrown) {
                    throw sink.syncErrorValue;
                }
            }
        }
        return sink;
    };
    Observable.prototype._trySubscribe = function (sink) {
        try {
            return this._subscribe(sink);
        }
        catch (err) {
            if (config.useDeprecatedSynchronousErrorHandling) {
                sink.syncErrorThrown = true;
                sink.syncErrorValue = err;
            }
            if (canReportError(sink)) {
                sink.error(err);
            }
            else {
                console.warn(err);
            }
        }
    };
    Observable.prototype.forEach = function (next, promiseCtor) {
        var _this = this;
        promiseCtor = getPromiseCtor(promiseCtor);
        return new promiseCtor(function (resolve, reject) {
            var subscription;
            subscription = _this.subscribe(function (value) {
                try {
                    next(value);
                }
                catch (err) {
                    reject(err);
                    if (subscription) {
                        subscription.unsubscribe();
                    }
                }
            }, reject, resolve);
        });
    };
    Observable.prototype._subscribe = function (subscriber) {
        var source = this.source;
        return source && source.subscribe(subscriber);
    };
    Observable.prototype[observable] = function () {
        return this;
    };
    Observable.prototype.pipe = function () {
        var operations = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            operations[_i] = arguments[_i];
        }
        if (operations.length === 0) {
            return this;
        }
        return pipeFromArray(operations)(this);
    };
    Observable.prototype.toPromise = function (promiseCtor) {
        var _this = this;
        promiseCtor = getPromiseCtor(promiseCtor);
        return new promiseCtor(function (resolve, reject) {
            var value;
            _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
        });
    };
    Observable.create = function (subscribe) {
        return new Observable(subscribe);
    };
    return Observable;
}());
function getPromiseCtor(promiseCtor) {
    if (!promiseCtor) {
        promiseCtor =  Promise;
    }
    if (!promiseCtor) {
        throw new Error('no Promise impl found');
    }
    return promiseCtor;
}
//# sourceMappingURL=Observable.js.map

function tnLineStdinReader() {
  return new Observable(subscribe => {
    const stdin = readline.createInterface(process.stdin);
    let tests = null;
    let n = null;
    stdin.on('line', line => {
      if (tests === null) {
        tests = +line;
      } else if (n === null) {
        n = +line;
        tests--;
      } else {
        n = null;
        subscribe.next(line);

        if (tests === 0) {
          stdin.close();
          subscribe.complete();
        }
      }
    });
  });
}

function isHappy(arr) {
  if (arr[0] <= 0 || arr[arr.length - 1] <= 0) {
    return 'NO';
  }

  let sum = 0;

  for (let x = 0; x < arr.length - 1; x++) {
    sum += arr[x];

    if (sum <= 0) {
      return 'NO';
    }
  }

  sum = 0;

  for (let x = arr.length - 1; x > 0; x--) {
    sum += arr[x];

    if (sum <= 0) {
      return 'NO';
    }
  }

  return 'YES';
}

tnLineStdinReader().subscribe(input => {
  const arr = input.split(' ').map(i => +i);
  console.log(isHappy(arr));
});

'use strict'

let t = parseInt(readline())

function calc (arr) {
    let max_so_far = Number.MIN_SAFE_INTEGER
    let max_here = 0

    for (let i = 0; i + 1 < arr.length; ++i) {
        max_here += arr[i]

        if (max_here < 0) {
            max_here = 0
        }

        if (max_so_far < max_here) {
            max_so_far = max_here
        }
    }
    return max_so_far
}

while (t --> 0) {
    const n = readline()
    const arr = readline().split(' ').map(function(x) {
        return parseInt(x)
    })

    let whole = 0
    for (let i in arr) whole += arr[i]

    let a = calc(arr)
    let b = calc(arr.reverse())

    let mx = Math.max(a, b)
    let ok = whole > mx

    print(ok ? 'YES': 'NO')
}

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

// function print(item) {
//   console.log(item);
// }

function maxSubArraySum(array_of_numbers, init_value, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = init_value; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    var cupcakes_count = parseInt(readline(), 10);
    var cupcakes_taste = readline().trim().split(' ').map(string => parseInt(string, 10));

    var total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    var result_begin = maxSubArraySum(cupcakes_taste, 0, cupcakes_count - 1);
    var result_end = maxSubArraySum(cupcakes_taste, 1, cupcakes_count);

    if (total_taste > Math.max(result_begin.max_so_far, result_end.max_so_far)) {
      print('YES');
    } else {
      print('NO');
    }
  }
}

main();

'use strict';

var readline = require('readline');

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function isFunction(x) {
    return typeof x === 'function';
}
//# sourceMappingURL=isFunction.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var _enable_super_gross_mode_that_will_cause_bad_things = false;
var config = {
    Promise: undefined,
    set useDeprecatedSynchronousErrorHandling(value) {
        if (value) {
            var error = /*@__PURE__*/ new Error();
            /*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
        }
        _enable_super_gross_mode_that_will_cause_bad_things = value;
    },
    get useDeprecatedSynchronousErrorHandling() {
        return _enable_super_gross_mode_that_will_cause_bad_things;
    },
};
//# sourceMappingURL=config.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function hostReportError(err) {
    setTimeout(function () { throw err; }, 0);
}
//# sourceMappingURL=hostReportError.js.map

/** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
var empty = {
    closed: true,
    next: function (value) { },
    error: function (err) {
        if (config.useDeprecatedSynchronousErrorHandling) {
            throw err;
        }
        else {
            hostReportError(err);
        }
    },
    complete: function () { }
};
//# sourceMappingURL=Observer.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
//# sourceMappingURL=isArray.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function isObject(x) {
    return x !== null && typeof x === 'object';
}
//# sourceMappingURL=isObject.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
    function UnsubscriptionErrorImpl(errors) {
        Error.call(this);
        this.message = errors ?
            errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n  ') : '';
        this.name = 'UnsubscriptionError';
        this.errors = errors;
        return this;
    }
    UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
    return UnsubscriptionErrorImpl;
})();
var UnsubscriptionError = UnsubscriptionErrorImpl;
//# sourceMappingURL=UnsubscriptionError.js.map

/** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
var Subscription = /*@__PURE__*/ (function () {
    function Subscription(unsubscribe) {
        this.closed = false;
        this._parentOrParents = null;
        this._subscriptions = null;
        if (unsubscribe) {
            this._unsubscribe = unsubscribe;
        }
    }
    Subscription.prototype.unsubscribe = function () {
        var errors;
        if (this.closed) {
            return;
        }
        var _a = this, _parentOrParents = _a._parentOrParents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
        this.closed = true;
        this._parentOrParents = null;
        this._subscriptions = null;
        if (_parentOrParents instanceof Subscription) {
            _parentOrParents.remove(this);
        }
        else if (_parentOrParents !== null) {
            for (var index = 0; index < _parentOrParents.length; ++index) {
                var parent_1 = _parentOrParents[index];
                parent_1.remove(this);
            }
        }
        if (isFunction(_unsubscribe)) {
            try {
                _unsubscribe.call(this);
            }
            catch (e) {
                errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
            }
        }
        if (isArray(_subscriptions)) {
            var index = -1;
            var len = _subscriptions.length;
            while (++index < len) {
                var sub = _subscriptions[index];
                if (isObject(sub)) {
                    try {
                        sub.unsubscribe();
                    }
                    catch (e) {
                        errors = errors || [];
                        if (e instanceof UnsubscriptionError) {
                            errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
                        }
                        else {
                            errors.push(e);
                        }
                    }
                }
            }
        }
        if (errors) {
            throw new UnsubscriptionError(errors);
        }
    };
    Subscription.prototype.add = function (teardown) {
        var subscription = teardown;
        if (!teardown) {
            return Subscription.EMPTY;
        }
        switch (typeof teardown) {
            case 'function':
                subscription = new Subscription(teardown);
            case 'object':
                if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
                    return subscription;
                }
                else if (this.closed) {
                    subscription.unsubscribe();
                    return subscription;
                }
                else if (!(subscription instanceof Subscription)) {
                    var tmp = subscription;
                    subscription = new Subscription();
                    subscription._subscriptions = [tmp];
                }
                break;
            default: {
                throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
            }
        }
        var _parentOrParents = subscription._parentOrParents;
        if (_parentOrParents === null) {
            subscription._parentOrParents = this;
        }
        else if (_parentOrParents instanceof Subscription) {
            if (_parentOrParents === this) {
                return subscription;
            }
            subscription._parentOrParents = [_parentOrParents, this];
        }
        else if (_parentOrParents.indexOf(this) === -1) {
            _parentOrParents.push(this);
        }
        else {
            return subscription;
        }
        var subscriptions = this._subscriptions;
        if (subscriptions === null) {
            this._subscriptions = [subscription];
        }
        else {
            subscriptions.push(subscription);
        }
        return subscription;
    };
    Subscription.prototype.remove = function (subscription) {
        var subscriptions = this._subscriptions;
        if (subscriptions) {
            var subscriptionIndex = subscriptions.indexOf(subscription);
            if (subscriptionIndex !== -1) {
                subscriptions.splice(subscriptionIndex, 1);
            }
        }
    };
    Subscription.EMPTY = (function (empty) {
        empty.closed = true;
        return empty;
    }(new Subscription()));
    return Subscription;
}());
function flattenUnsubscriptionErrors(errors) {
    return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
}
//# sourceMappingURL=Subscription.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var rxSubscriber = /*@__PURE__*/ (function () {
    return typeof Symbol === 'function'
        ? /*@__PURE__*/ Symbol('rxSubscriber')
        : '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
})();
//# sourceMappingURL=rxSubscriber.js.map

/** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
var Subscriber = /*@__PURE__*/ (function (_super) {
    __extends(Subscriber, _super);
    function Subscriber(destinationOrNext, error, complete) {
        var _this = _super.call(this) || this;
        _this.syncErrorValue = null;
        _this.syncErrorThrown = false;
        _this.syncErrorThrowable = false;
        _this.isStopped = false;
        switch (arguments.length) {
            case 0:
                _this.destination = empty;
                break;
            case 1:
                if (!destinationOrNext) {
                    _this.destination = empty;
                    break;
                }
                if (typeof destinationOrNext === 'object') {
                    if (destinationOrNext instanceof Subscriber) {
                        _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
                        _this.destination = destinationOrNext;
                        destinationOrNext.add(_this);
                    }
                    else {
                        _this.syncErrorThrowable = true;
                        _this.destination = new SafeSubscriber(_this, destinationOrNext);
                    }
                    break;
                }
            default:
                _this.syncErrorThrowable = true;
                _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
                break;
        }
        return _this;
    }
    Subscriber.prototype[rxSubscriber] = function () { return this; };
    Subscriber.create = function (next, error, complete) {
        var subscriber = new Subscriber(next, error, complete);
        subscriber.syncErrorThrowable = false;
        return subscriber;
    };
    Subscriber.prototype.next = function (value) {
        if (!this.isStopped) {
            this._next(value);
        }
    };
    Subscriber.prototype.error = function (err) {
        if (!this.isStopped) {
            this.isStopped = true;
            this._error(err);
        }
    };
    Subscriber.prototype.complete = function () {
        if (!this.isStopped) {
            this.isStopped = true;
            this._complete();
        }
    };
    Subscriber.prototype.unsubscribe = function () {
        if (this.closed) {
            return;
        }
        this.isStopped = true;
        _super.prototype.unsubscribe.call(this);
    };
    Subscriber.prototype._next = function (value) {
        this.destination.next(value);
    };
    Subscriber.prototype._error = function (err) {
        this.destination.error(err);
        this.unsubscribe();
    };
    Subscriber.prototype._complete = function () {
        this.destination.complete();
        this.unsubscribe();
    };
    Subscriber.prototype._unsubscribeAndRecycle = function () {
        var _parentOrParents = this._parentOrParents;
        this._parentOrParents = null;
        this.unsubscribe();
        this.closed = false;
        this.isStopped = false;
        this._parentOrParents = _parentOrParents;
        return this;
    };
    return Subscriber;
}(Subscription));
var SafeSubscriber = /*@__PURE__*/ (function (_super) {
    __extends(SafeSubscriber, _super);
    function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
        var _this = _super.call(this) || this;
        _this._parentSubscriber = _parentSubscriber;
        var next;
        var context = _this;
        if (isFunction(observerOrNext)) {
            next = observerOrNext;
        }
        else if (observerOrNext) {
            next = observerOrNext.next;
            error = observerOrNext.error;
            complete = observerOrNext.complete;
            if (observerOrNext !== empty) {
                context = Object.create(observerOrNext);
                if (isFunction(context.unsubscribe)) {
                    _this.add(context.unsubscribe.bind(context));
                }
                context.unsubscribe = _this.unsubscribe.bind(_this);
            }
        }
        _this._context = context;
        _this._next = next;
        _this._error = error;
        _this._complete = complete;
        return _this;
    }
    SafeSubscriber.prototype.next = function (value) {
        if (!this.isStopped && this._next) {
            var _parentSubscriber = this._parentSubscriber;
            if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                this.__tryOrUnsub(this._next, value);
            }
            else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.error = function (err) {
        if (!this.isStopped) {
            var _parentSubscriber = this._parentSubscriber;
            var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
            if (this._error) {
                if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                    this.__tryOrUnsub(this._error, err);
                    this.unsubscribe();
                }
                else {
                    this.__tryOrSetError(_parentSubscriber, this._error, err);
                    this.unsubscribe();
                }
            }
            else if (!_parentSubscriber.syncErrorThrowable) {
                this.unsubscribe();
                if (useDeprecatedSynchronousErrorHandling) {
                    throw err;
                }
                hostReportError(err);
            }
            else {
                if (useDeprecatedSynchronousErrorHandling) {
                    _parentSubscriber.syncErrorValue = err;
                    _parentSubscriber.syncErrorThrown = true;
                }
                else {
                    hostReportError(err);
                }
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.complete = function () {
        var _this = this;
        if (!this.isStopped) {
            var _parentSubscriber = this._parentSubscriber;
            if (this._complete) {
                var wrappedComplete = function () { return _this._complete.call(_this._context); };
                if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                    this.__tryOrUnsub(wrappedComplete);
                    this.unsubscribe();
                }
                else {
                    this.__tryOrSetError(_parentSubscriber, wrappedComplete);
                    this.unsubscribe();
                }
            }
            else {
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
        try {
            fn.call(this._context, value);
        }
        catch (err) {
            this.unsubscribe();
            if (config.useDeprecatedSynchronousErrorHandling) {
                throw err;
            }
            else {
                hostReportError(err);
            }
        }
    };
    SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
        if (!config.useDeprecatedSynchronousErrorHandling) {
            throw new Error('bad call');
        }
        try {
            fn.call(this._context, value);
        }
        catch (err) {
            if (config.useDeprecatedSynchronousErrorHandling) {
                parent.syncErrorValue = err;
                parent.syncErrorThrown = true;
                return true;
            }
            else {
                hostReportError(err);
                return true;
            }
        }
        return false;
    };
    SafeSubscriber.prototype._unsubscribe = function () {
        var _parentSubscriber = this._parentSubscriber;
        this._context = null;
        this._parentSubscriber = null;
        _parentSubscriber.unsubscribe();
    };
    return SafeSubscriber;
}(Subscriber));
//# sourceMappingURL=Subscriber.js.map

/** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
function canReportError(observer) {
    while (observer) {
        var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
        if (closed_1 || isStopped) {
            return false;
        }
        else if (destination && destination instanceof Subscriber) {
            observer = destination;
        }
        else {
            observer = null;
        }
    }
    return true;
}
//# sourceMappingURL=canReportError.js.map

/** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
function toSubscriber(nextOrObserver, error, complete) {
    if (nextOrObserver) {
        if (nextOrObserver instanceof Subscriber) {
            return nextOrObserver;
        }
        if (nextOrObserver[rxSubscriber]) {
            return nextOrObserver[rxSubscriber]();
        }
    }
    if (!nextOrObserver && !error && !complete) {
        return new Subscriber(empty);
    }
    return new Subscriber(nextOrObserver, error, complete);
}
//# sourceMappingURL=toSubscriber.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
//# sourceMappingURL=observable.js.map

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function noop() { }
//# sourceMappingURL=noop.js.map

/** PURE_IMPORTS_START _noop PURE_IMPORTS_END */
function pipeFromArray(fns) {
    if (!fns) {
        return noop;
    }
    if (fns.length === 1) {
        return fns[0];
    }
    return function piped(input) {
        return fns.reduce(function (prev, fn) { return fn(prev); }, input);
    };
}
//# sourceMappingURL=pipe.js.map

/** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
var Observable = /*@__PURE__*/ (function () {
    function Observable(subscribe) {
        this._isScalar = false;
        if (subscribe) {
            this._subscribe = subscribe;
        }
    }
    Observable.prototype.lift = function (operator) {
        var observable = new Observable();
        observable.source = this;
        observable.operator = operator;
        return observable;
    };
    Observable.prototype.subscribe = function (observerOrNext, error, complete) {
        var operator = this.operator;
        var sink = toSubscriber(observerOrNext, error, complete);
        if (operator) {
            sink.add(operator.call(sink, this.source));
        }
        else {
            sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
                this._subscribe(sink) :
                this._trySubscribe(sink));
        }
        if (config.useDeprecatedSynchronousErrorHandling) {
            if (sink.syncErrorThrowable) {
                sink.syncErrorThrowable = false;
                if (sink.syncErrorThrown) {
                    throw sink.syncErrorValue;
                }
            }
        }
        return sink;
    };
    Observable.prototype._trySubscribe = function (sink) {
        try {
            return this._subscribe(sink);
        }
        catch (err) {
            if (config.useDeprecatedSynchronousErrorHandling) {
                sink.syncErrorThrown = true;
                sink.syncErrorValue = err;
            }
            if (canReportError(sink)) {
                sink.error(err);
            }
            else {
                console.warn(err);
            }
        }
    };
    Observable.prototype.forEach = function (next, promiseCtor) {
        var _this = this;
        promiseCtor = getPromiseCtor(promiseCtor);
        return new promiseCtor(function (resolve, reject) {
            var subscription;
            subscription = _this.subscribe(function (value) {
                try {
                    next(value);
                }
                catch (err) {
                    reject(err);
                    if (subscription) {
                        subscription.unsubscribe();
                    }
                }
            }, reject, resolve);
        });
    };
    Observable.prototype._subscribe = function (subscriber) {
        var source = this.source;
        return source && source.subscribe(subscriber);
    };
    Observable.prototype[observable] = function () {
        return this;
    };
    Observable.prototype.pipe = function () {
        var operations = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            operations[_i] = arguments[_i];
        }
        if (operations.length === 0) {
            return this;
        }
        return pipeFromArray(operations)(this);
    };
    Observable.prototype.toPromise = function (promiseCtor) {
        var _this = this;
        promiseCtor = getPromiseCtor(promiseCtor);
        return new promiseCtor(function (resolve, reject) {
            var value;
            _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
        });
    };
    Observable.create = function (subscribe) {
        return new Observable(subscribe);
    };
    return Observable;
}());
function getPromiseCtor(promiseCtor) {
    if (!promiseCtor) {
        promiseCtor =  Promise;
    }
    if (!promiseCtor) {
        throw new Error('no Promise impl found');
    }
    return promiseCtor;
}
//# sourceMappingURL=Observable.js.map

function tnLineStdinReader() {
  return new Observable(function (subscribe) {
    var stdin = readline.createInterface(process.stdin);
    var tests = null;
    var n = null;
    stdin.on('line', function (line) {
      if (tests === null) {
        tests = +line;
      } else if (n === null) {
        n = +line;
        tests--;
      } else {
        n = null;
        subscribe.next(line);

        if (tests === 0) {
          stdin.close();
          subscribe.complete();
        }
      }
    });
  });
}

function isHappy(arr) {
  if (arr[0] <= 0 || arr[arr.length - 1] <= 0) {
    return 'NO';
  }

  var sum = 0;

  for (var x = 0; x < arr.length - 2; x++) {
    sum += arr[x];

    if (sum <= 0) {
      return 'NO';
    }
  }

  sum = 0;

  for (var _x = arr.length - 1; _x > 0; _x--) {
    sum += arr[_x];

    if (sum <= 0) {
      return 'NO';
    }
  }

  return 'YES';
}

tnLineStdinReader().subscribe(function (input) {
  var arr = input.split(' ').map(function (i) {
    return +i;
  });
  console.log(isHappy(arr));
});

'use strict'

let t = parseInt(readline())
while (t --> 0) {
    const n = parseInt(readline())
    const arr = readline().split(' ').map(function(x) {
        return parseInt(x)
    })

    let max_so_far = Number.MIN_SAFE_INTEGER
    let max_here = 0
    let neg = false

    for (let i = 0; i < n; ++i) {
        if (arr[i] < 0) neg = true
        max_here += arr[i]

        if (max_here < 0) {
            max_here = 0
        }

        if (max_so_far < max_here) {
            max_so_far = max_here
        }
    }

    let ok = false
    if (max_so_far < max_here) {
        ok = true
    } else if (max_so_far == max_here) {
        if (!neg) ok = true
    }

    print(ok ? 'YES': 'NO')
}

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var arr=readline().split(" ");

    var tot=0;
    var seg=0;
    var maxSeg=0;
    var totCt=0;
    var segCt=0;

    //print(arr);

    for(var i=0;i<arr.length;i++){
        var num=parseInt(arr[i],10);
        tot+=num; totCt++;
        if(seg+num<=0){seg=0;segCt=0;}//go below zero by adding this number, start a new segment
        else{seg+=num;segCt++;if(maxSeg<seg){maxSeg=seg;}}
        //if(num>0){seg+=num; if(maxSeg<seg){maxSeg=seg;}}
        //if(num<0){noNeg=true; seg=0;}//segment will not be all numbers
    }

    //print("tot: "+tot)
    //print("max seg: "+maxSeg)

    if(tot>maxSeg||(segCt==totCt&&tot==maxSeg)){print("YES");}
    else{print("NO");}

}//num runs

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var arr=readline().split(" ").map(function(x){return parseInt(x);});

    var tot=0;
    var seg=0;
    var maxSeg=0;
    var totCt=0;
    var segCt=0;

    //print(arr);

    for(var i=0;i<arr.length;i++){
        //var num=parseInt(arr[i],10);
        var num=arr[i];
        tot+=num; totCt++;
        if(seg+num<=0){seg=0;segCt=0;}//go below zero by adding this number, start a new segment
        else{seg+=num;segCt++;if(seg>maxSeg){maxSeg=seg;}}
        //if(num>0){seg+=num; if(maxSeg<seg){maxSeg=seg;}}
        //if(num<0){noNeg=true; seg=0;}//segment will not be all numbers
    }

    //print("tot:"+tot+" totCt:"+totCt)
   // print("max seg:"+maxSeg+" segCt:"+segCt)

    if(tot>maxSeg||(segCt==totCt&&tot==maxSeg&&arr[0]!=0&&arr[arr.length-1]!=0)){print("YES");}
    else{print("NO");}

}//num runs

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var arr=readline().split(" ").map(function(x){return parseInt(x);});

    var tot=0;
    var seg=0;
    var maxSeg=0;
    var totCt=0;
    var segCt=0;

    //print(arr);

    for(var i=0;i<arr.length;i++){
        //var num=parseInt(arr[i],10);
        var num=arr[i];
        tot+=num; totCt++;
        if(seg+num<=0){seg=0;segCt=0;}//go below zero by adding this number, start a new segment
        else{seg+=num;segCt++;if(seg>maxSeg){maxSeg=seg;}}
        //if(num>0){seg+=num; if(maxSeg<seg){maxSeg=seg;}}
        //if(num<0){noNeg=true; seg=0;}//segment will not be all numbers
    }

    //print("tot:"+tot+" totCt:"+totCt)
    //print("max seg:"+maxSeg+" segCt:"+segCt)

    if(tot>maxSeg||(segCt==totCt&&tot==maxSeg)){print("YES");}
    else{print("NO");}

}//num runs

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var arr=readline().split(" ").map(function(x){return parseInt(x);});

    var tot=0;
    var seg=0;
    var maxSeg=0;
    var totCt=0;
    var segCt=0;

    //print(arr);

    for(var i=0;i<arr.length;i++){
        //var num=parseInt(arr[i],10);
        var num=arr[i];
        tot+=num; totCt++;
        if(seg+num<=0){seg=0;segCt=0;}//go below zero by adding this number, start a new segment
        else{seg+=num;segCt++;if(seg>maxSeg){maxSeg=seg;}}
        //if(num>0){seg+=num; if(maxSeg<seg){maxSeg=seg;}}
        //if(num<0){noNeg=true; seg=0;}//segment will not be all numbers
    }

    print("tot:"+tot+" totCt:"+totCt)
    print("max seg:"+maxSeg+" segCt:"+segCt)

    if(tot>maxSeg||(segCt==totCt&&tot==maxSeg&&arr[0]!=0&&arr[arr.length-1]!=0)){print("YES");}
    else{print("NO");}

}//num runs

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var arr=readline().split(" ");

    var tot=0;
    var seg=0;
    var maxSeg=0;
    var noNeg=false;

    //print(arr);

    for(var i=0;i<arr.length;i++){
        var num=parseInt(arr[i],10);
        tot+=num;
        if(num>0){seg+=num; if(maxSeg<seg){maxSeg=seg;}}
        if(num<0){noNeg=true; seg=0;}//segment will not be all numbers
    }

    //print("tot: "+tot)
    //print("max seg: "+maxSeg)

    if(tot>maxSeg||!noNeg){print("YES");}
    else{print("NO");}

}//num runs

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = parseInt(readline(), 10);
    const cupcakes_taste = readline().trim().split(' ').map(string => parseInt(string, 10));

    const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
      print('YES');
    } else {
      if (total_taste > result.max_so_far) {
        print('YES');
      } else {
        print('NO');
      }
    }
  }
}
main();

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

main();

function main() {
  const test_cases = readline();
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = readline();
    const cupcakes_taste = readline(); //.trim().split(' ').map(string => parseInt(string, 10));

    // const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    // const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    print(cupcakes_count, cupcakes_taste);
    // if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
    //   print('YES');
    // } else {
    //   if (total_taste > result.max_so_far) {
    //     print('YES');
    //   } else {
    //     print('NO');
    //   }
    // }
  }
}

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = parseInt(readline(), 10);
    const cupcakes_taste = readline(); //.trim().split(' ').map(string => parseInt(string, 10));

    // const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    // const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    print(cupcakes_taste);
    // if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
    //   print('YES');
    // } else {
    //   if (total_taste > result.max_so_far) {
    //     print('YES');
    //   } else {
    //     print('NO');
    //   }
    // }
  }
}
main();

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    var cupcakes_count = parseInt(readline(), 10);
    var cupcakes_taste = readline().trim().split(' ').map(string => parseInt(string, 10));

    var total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    var result = maxSubArraySum(cupcakes_taste, cupcakes_count);

    if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
      print('YES');
    } else {
      if (total_taste > result.max_so_far) {
        print('YES');
      } else {
        print('NO');
      }
    }
  }
}
main();

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = readline();
    const cupcakes_taste = readline(); //.trim().split(' ').map(string => parseInt(string, 10));

    // const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    // const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    print(cupcakes_count, cupcakes_taste);
    // if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
    //   print('YES');
    // } else {
    //   if (total_taste > result.max_so_far) {
    //     print('YES');
    //   } else {
    //     print('NO');
    //   }
    // }
  }
}
main();

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = parseInt(readline(), 10);
    const cupcakes_taste = readline().trim().split(' ').map(string => parseInt(string, 10));

    const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    print(cupcakes_taste, total_taste, result)
    // if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
    //   print('YES');
    // } else {
    //   if (total_taste > result.max_so_far) {
    //     print('YES');
    //   } else {
    //     print('NO');
    //   }
    // }
  }
}
main();

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = parseInt(readline(), 10);
    const cupcakes_taste = readline(); //.trim().split(' ').map(string => parseInt(string, 10));

    // const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    // const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    print(cupcakes_count, cupcakes_taste);
    // if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
    //   print('YES');
    // } else {
    //   if (total_taste > result.max_so_far) {
    //     print('YES');
    //   } else {
    //     print('NO');
    //   }
    // }
  }
}
main();

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

// function print(item) {
//   console.log(item);
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = parseInt(readline(), 10);
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = parseInt(readline(), 10);
    const cupcakes_taste = readline().trim().split(' ').map(string => parseInt(string, 10));

    const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
      print('YES');
    } else {
      if (total_taste > result.max_so_far) {
        print('YES');
      } else {
        print('NO');
      }
    }
  }
}

main();

// 'use strict';

// process.stdin.resume();
// process.stdin.setEncoding('utf-8');

// let inputString = '';
// let currentLine = 0;

// process.stdin.on('data', inputStdin => {
//   inputString += inputStdin;
// });

// process.stdin.on('end', _ => {
//   inputString = inputString.trim().split('\n').map(string => {
//     return string.trim();
//   });

//   main();
// });

// function readline() {
//   return inputString[currentLine++];
// }

function maxSubArraySum(array_of_numbers, array_size) {
  var max_so_far = Number.MIN_SAFE_INTEGER;
  var max_ending_here = 0;
  var start_index = 0;
  var end_index = 0;
  var start_tmp = 0;

  for (var i = 0; i < array_size; i++) {
    max_ending_here += array_of_numbers[i];

    if (max_so_far < max_ending_here) {
      max_so_far = max_ending_here;
      start_index = start_tmp;
      end_index = i;
    }

    if (max_ending_here < 0) {
      max_ending_here = 0;
      start_tmp = i + 1;
    }
  }
  return { max_so_far, start_index, end_index };
}

function main() {
  const test_cases = readline();
  for(var i = 0; i < test_cases; i++) {
    const cupcakes_count = readline();
    const cupcakes_taste = readline(); //.trim().split(' ').map(string => parseInt(string, 10));

    // const total_taste = cupcakes_taste.reduce((a, b) => a + b, 0);

    // const result = maxSubArraySum(cupcakes_taste, cupcakes_count);
    print(cupcakes_count, cupcakes_taste);
    // if (result.start_index == 0 && result.end_index == cupcakes_count - 1) {
    //   print('YES');
    // } else {
    //   if (total_taste > result.max_so_far) {
    //     print('YES');
    //   } else {
    //     print('NO');
    //   }
    // }
  }
}
main();


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(BigInt)
        output[i] = solve(n, m)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m) {
    const [rn, c2n, c5n] = helper(n)
    let now = 1n
    if (c2n > c5n) {
        let k = 0n
        while (c2n >= c5n + k + 1n && now * 5n <= m) {
            k++
            now *= 5n
        }
        n *= now
        m = m / now
    } else if (c2n < c5n) {
        let k = 0n
        while (c2n + k + 1n <= c5n && now * 2n <= m) {
            k++
            now *= 2n
        }
        n *= now
        m = m / now
    }
        // console.log(c2n, c5n, now)
    const sm = m.toString()
    const base = sm.length - 1
    return n * (10n ** BigInt(base)) * BigInt(sm[0])
}
function helper(n) {
    let c2 = 0n, c5 = 0n
    while (n > 0n && !(n % 2n)) {
        n /= 2n
        c2++
    }
    while (n > 0n && !(n % 5n)) {
        n /= 5n
        c5++
    }
    return [n, c2, c5]
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [n, m] = rns();
  let len = 0,
      s = n.toString();
  for (let i = s.length - 1; i >= 0; i--) {
    if (s[i] === '0') len++;else break;
  }
  s = s.slice(0, s.length - len);
  let num = Number(s),
      res = 1;
  if (num % 5 === 0) {
    let cnt = 0;
    while (num % 5 === 0) {
      cnt++;
      num /= 5;
    }
    for (let i = cnt; i >= 0; i--) {
      if (2 ** i <= m) {
        res = 2 ** i;
        break;
      }
    }
  } else if (num % 2 === 0) {
    let cnt = 0;
    while (num % 2 === 0) {
      cnt++;
      num /= 2;
    }
    for (let i = cnt; i >= 0; i--) {
      if (5 ** i <= m) {
        res = 5 ** i;
        break;
      }
    }
  }
  for (; res * 10 <= m; res *= 10) {}
  const x = Math.floor(m / res);
  res *= x;
  return BigInt(n) * BigInt(res);
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var text = trim(readline());
	var match = text.match(/^([a-z]+\@[a-z])*([a-z]+\@[a-z]+)$/);
	if (match) {
		var regex = /[a-z]+\@[a-z]/g;
		var groups = [];
		while (true) {
			var result = regex.exec(text);
			if (result === null) {
				break;
			}
			groups.push(result[0]);
		}
		var tail = text.match(/[a-z]+$/)[0].substring(1);
		groups[groups.length-1] += tail;
		print(groups.join(","));
	}
	else {
		print("No solution");
	}
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var text = trim(readline());

	var groups = [];
	var start = 0;

	while (true) {

		var pos = text.indexOf("@", start);

		if (pos == -1) {
			if (groups.length == 0) {
				print("No solution");
			}
			else {
				groups[groups.length-1] += text.substring(start);
				print(groups.join(","));
			}
			return;
		}

		if (pos == start || pos == text.length-1 || text.charAt(pos+1) == '@') {
			print("No solution");
			return;
		}

		groups.push(text.substring(start, pos+2));
		start = pos+2;
	}
}

main();

var s = readline()
print((s.match(/^@|@.?@|@$/) || !~s.indexOf('@')) ? 'No solution' : s.match(/[a-z]+@[a-z]/g).join() + s.slice(s.lastIndexOf('@') + 2))

'use strict'

let lll = readline()

;(function () {
  let spt = lll.split('@')
  if (spt.length < 2) return print('No solution')
  if (!spt[0] || !spt[spt.length - 1]) return print('No solution')
  if (spt.slice(1, -1).length != spt.slice(1, -1).filter(v => v.length > 1).length)
    return print('No solution')

  let as
  if (spt.length > 2) {
    as = [spt[0] + '@' + spt[1][0]]
    for (let i = 1; i < spt.length - 2; i++) {
      as.push(spt[i].slice(1) + '@' + spt[i + 1][0])
    }
    as.push(spt[spt.length - 2].slice(1) + '@' + spt[spt.length - 1])
  } else {
    as = [spt.join('@')]
  }
  print(as.join(','))
}())

//var numbers = readline().split(" ").map(function(x) { return parseInt(x); });
var emails = readline();
var answ = [];
dropStr(emails);

function dropStr(str) {
    for (var i = 0; i < str.length; ++i) {
        if (str[i] == '@') {
            answ.push(str.substr(0, i+2));
            str = str.substr(i+2);
            break;
        }
    }
    if (str.length > 0 && str.indexOf('@') !== -1) {
        dropStr(str);
    } else {
        if (answ[answ.length-1])
          answ[answ.length-1] = answ[answ.length-1].concat(str);
    }
}
var status = false;
for (var i = 0; i < answ.length; ++i) {
    var splited_anws = answ[i].split('@');
    if (splited_anws[0].length === 0 || splited_anws[1].length === 0) {
        status = true;
    }
}

if (!status && answ.length !== 0) {
    print(answ);
} else {
    print('No solution');
}

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var text = trim(readline());
	var groups = text.match(/^([a-z]+\@[a-z])*([a-z]+\@[a-z]+)$/);
	if (groups) {
		groups.splice(0, 1);
		print(groups.join(","));
	}
	else {
		print("No solution");
	}
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var text = trim(readline());
	var match = text.match(/^([a-z]+\@[a-z])+$/);
	if (match) {
		var groups = text.match(/[a-z]+\@[a-z]/g);
		print(groups.join(","));
	}
	else {
		print("No solution");
	}
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var text = trim(readline());

	var groups = [];
	var start = 0;

	while (true) {

		var pos = text.indexOf("@", start);

		if (pos == -1) {
			if (groups.length == 0) {
				print("No solution");
			}
			else {
				groups[groups.length-1] += text.substring(start);
				print(groups.join(","));
			}
			return;
		}

		if (pos == start || pos == text.length-1) {
			print("No solution");
			return;
		}

		groups.push(text.substring(start, pos+2));
		start = pos+2;
	}
}

main();

var s = readline()
print(s.match(/^@|@.?@|@$/) ? 'No solution' : s.match(/[a-z]+@[a-z]/g).join())

var s = readline()
print(s.match(/^@|@.?@|@$/) || !~s.indexOf('@')) ? 'No solution' : s.match(/[a-z]+@[a-z]/g).join() + s.slice(s.lastIndexOf('@') + 2)

'use strict'

let lll = readline()

;(function () {
  let spt = lll.split('@')
  if (spt.length < 2) return print('No solution')
  if (!spt[0] || !spt[spt.length - 1]) return print('No solution')
  if (spt.slice(1, -1).length != spt.slice(1, -1).filter(v => v.length > 1).length)
    return print('No solution')

  let as = [spt[0] + '@' + spt[1][0]]
  for (let i = 1; i < spt.length - 2; i++) {
    as.push(spt[i].slice(1) + '@' + spt[i + 1][0])
  }
  as.push(spt[spt.length - 2].slice(1) + '@' + spt[spt.length - 1])
  print(as.join(','))
}())


var n = parseInt(readline());
var a = new Array();
for(var i=0;i<n;i++)
{
    var b = readline().split(' ');
	a[i]=new Array();
	for(var j=0;j<b.length;j++)
	{
	    a[i][j]=parseInt(b[j]);
	}
}
// check
var isOK = 1;
for(var i=0;i<n;i++)
{
    if(a[i][i]!=0)
	{
	    isOK=0;
		break;
	}
	for(var j=i+1;j<n;j++)
	{
	    if(a[i][j]!=a[j][i] || a[i][j]==0)
		{
		    isOK=0;
			break;
		}
	}
}

// used: the list of ids which are used
var used = new Array();
used[0]=0;

// u[i]=1 -> node i is used.
var u = new Array();
for(var i=0;i<n;i++)
{
    u[i]=0;
}
u[0]=1;

if(isOK==0)
{
    print("NO");
}
else{
    var k=1;
    while(k<n)
    {
        // get the nearest node to node 0
	    var next_node = getNextNode();
		// get the parent node of next_node
		var pnode = getNearestNode(next_node);

		for(var i=0;i<used.length;i++)
		{
		    if(a[used[i]][pnode]+a[next_node][pnode]!=a[used[i]][next_node])
			{
			    isOK=0;
				break;
			}
		}
		if(isOK==1)
		{
		    used[used.length]=next_node;
		}
        else
	    {
	        break;
	    }
	    k++;
    }
    if(isOK==1)
    {
        print("YES");
    }
    else
    {
        print("NO");
    }
}

function getNextNode()
{
    var nd = -1;
	for(var i=0;i<n;i++)
	{
	    if(u[i]==0&&nd==-1)
		{
		    nd=i;
		}
		else if(u[i]==0&&nd!=-1)
		{
		    if(a[0][i]<a[0][nd])
			{
			    nd=i;
			}
		}
	}
	u[nd]=1;
	return nd;
}

function getNearestNode( nid )
{
   var pnode =used[0];
   for(var i=1;i<used.length;i++)
   {
       if(a[used[i]][nid]<a[pnode][nid])
	   {
	       pnode= used[i];
	   }
   }
   return pnode;
}

var n = parseInt(readline());
var a = new Array();
for(var i=0;i<n;i++)
{
    var b = readline().split(' ');
	a[i]=new Array();
	for(var j=0;j<b.length;j++)
	{
	    a[i][j]=parseInt(b[j]);
	}
}
// check
var isOK = 1;
for(var i=0;i<n;i++)
{
    if(a[i][i]!=0)
	{
	    isOK=0;
		break;
	}
	for(var j=i+1;j<n;j++)
	{
	    if(a[i][j]!=a[j][i] || a[i][j]==0)
		{
		    isOK=0;
			break;
		}
	}
	if(isOK==0)
	{
	    break;
	}
}

// used the array of ids which are used
var used = new Array();
used[0]=0;

var u = new Array();
for(var i=0;i<n;i++)
{
    u[i]=0;
}
u[0]=1;

if(isOK==0)
{
print("NO");
}
else{
    var k=1;
    while(k<n)
    {
        // get the nearest node of node 0
	    var tid = getNextNode();
		var i = getNearestNode(tid);

	    // parent id is node used[i]
		for(var j=0;j<used.length;j++)
		{
		    if(a[i][used[j]]+a[tid][i]!=a[used[j]][tid])
			{
			    isOK=0;
				break;
			}
		}
		if(isOK==1)
		{
		    used[used.length]=tid;
		}
        else
	    {
	        break;
	    }
	    k++;
    }
if(isOK==1)
{
    print("YES");
}
else
{
    print("NO");
}
}

function getNextNode()
{
    var fd = -1;
	for(var i=0;i<n;i++)
	{
	    if(u[i]==0&&fd==-1)
		{
		    fd=i;
		}
		else if(u[i]==0&&fd!=-1)
		{
		    if(a[0][i]<a[0][fd])
			{
			    fd=i;
			}
		}
	}
	u[fd]=1;
	return fd;
}

function getNearestNode( tid )
{
   var fd =used[0];
   for(var i=1;i<used.length;i++)
   {
       if(a[used[i]][tid]<a[fd][tid])
	   {
	       fd= used[i];
	   }
   }
   return fd;
}

var n = parseInt(readline());
var a = new Array();
for(var i=0;i<n;i++)
{
    var b = readline().split(' ');
	a[i]=new Array();
	for(var j=0;j<b.length;j++)
	{
	    a[i][j]=parseInt(b[j]);
	}
}
// check
var isOK = 1;
for(var i=0;i<n;i++)
{
	for(var j=i+1;j<n;j++)
	{
	    if(a[i][j]!=a[j][i] || a[i][j]==0)
		{
		    isOK=0;
			break;
		}
	}
}

// used: the list of ids which are used
var used = new Array();
used[0]=0;

// u[i]=1 -> node i is used.
var u = new Array();
for(var i=0;i<n;i++)
{
    u[i]=0;
}
u[0]=1;

if(isOK==0)
{
    print("NO");
}
else{
    var k=1;
    while(k<n)
    {
        // get the nearest node to node 0
	    var next_node = getNextNode();
		// get the parent node of next_node
		var pnode = getNearestNode(next_node);

		for(var i=0;i<used.length;i++)
		{
		    if(a[used[i]][pnode]+a[next_node][pnode]!=a[used[i]][next_node])
			{
			    isOK=0;
				break;
			}
		}
		if(isOK==1)
		{
		    used[used.length]=next_node;
		}
        else
	    {
	        break;
	    }
	    k++;
    }
    if(isOK==1)
    {
        print("YES");
    }
    else
    {
        print("NO");
    }
}

function getNextNode()
{
    var nd = -1;
	for(var i=0;i<n;i++)
	{
	    if(u[i]==0&&nd==-1)
		{
		    nd=i;
		}
		else if(u[i]==0&&nd!=-1)
		{
		    if(a[0][i]<a[0][nd])
			{
			    nd=i;
			}
		}
	}
	u[nd]=1;
	return nd;
}

function getNearestNode( nid )
{
   var pnode =used[0];
   for(var i=1;i<used.length;i++)
   {
       if(a[used[i]][nid]<a[pnode][nid])
	   {
	       pnode= used[i];
	   }
   }
   return pnode;
}

var n = parseInt(readline());
var a = new Array();
for(var i=0;i<n;i++)
{
    var b = readline().split(' ');
	a[i]=new Array();
	for(var j=0;j<b.length;j++)
	{
	    a[i][j]=parseInt(b[j]);
	}
}
// check
var isOK = 1;
for(var i=0;i<n;i++)
{
    if(a[i][i]!=0)
	{
	    isOK=0;
		break;
	}
	for(var j=i+1;j<n;j++)
	{
	    if(a[i][j]!=a[j][i])
		{
		    isOK=0;
			break;
		}
		if(a[i][j]==0)
		{
		    isOK=0;
			break;
		}
	}
	if(isOK==0)
	{
	    break;
	}
}

var x=new Array();
if(isOK==0)
{
    print("NO");
}
else if(n<=2)
{
    print("YES");
}
else
{
    x[0] = 0;
	x[1] = a[0][1];
	for(var i=2;i<n;i++)
	{
	    isOK=1;
	    for(var k=-1;k<=1;k+=2)
		{
		    isOK = 1;
			x[i]=k*a[0][i];
		    for(var j=0;j<i;j++)
			{
			    if(Math.abs(x[i]-x[j])!=a[i][j])
				{
//				print(i+': '+x[i] +j);
				    isOK=0;
					break;
				}
			}
			if(isOK==1)
			{
			    break;
			}
		}
		if(isOK==0)
		{
		    break;
		}
	}
	if(isOK==0)
	{
	    print("NO");
	}
	else
	{
	    print("YES");
	}
}

var n = parseInt(readline());
var a = new Array();
for(var i=0;i<n;i++)
{
    var b = readline().split(' ');
	a[i]=new Array();
	for(var j=0;j<b.length;j++)
	{
	    a[i][j]=parseInt(b[j]);
	}
}
// check
var isOK = 1;
for(var i=0;i<n;i++)
{
	for(var j=i+1;j<n;j++)
	{
	    if(a[i][j]!=a[j][i] || a[i][j]==0)
		{
		    isOK=0;
			break;
		}
	}
}

// used the list of ids which are used
var used = new Array();
used[0]=0;

// u[i]=1 -> node i is used.
var u = new Array();
for(var i=0;i<n;i++)
{
    u[i]=0;
}
u[0]=1;

if(isOK==0)
{
    print("NO");
}
else{
    var k=1;
    while(k<n)
    {
        // get the nearest node to node 0
	    var next_node = getNextNode();
		// get the parent node of next_node
		var pnode = getNearestNode(next_node);

		for(var i=0;i<used.length;i++)
		{
		    if(a[next_node][used[i]]+a[next_node][pnode]!=a[used[i]][next_node])
			{
			    isOK=0;
				break;
			}
		}
		if(isOK==1)
		{
		    used[used.length]=next_node;
		}
        else
	    {
	        break;
	    }
	    k++;
    }
    if(isOK==1)
    {
        print("YES");
    }
    else
    {
        print("NO");
    }
}

function getNextNode()
{
    var nd = -1;
	for(var i=0;i<n;i++)
	{
	    if(u[i]==0&&nd==-1)
		{
		    nd=i;
		}
		else if(u[i]==0&&nd!=-1)
		{
		    if(a[0][i]<a[0][nd])
			{
			    nd=i;
			}
		}
	}
	u[nd]=1;
	return nd;
}

function getNearestNode( nid )
{
   var pnode =used[0];
   for(var i=1;i<used.length;i++)
   {
       if(a[used[i]][nid]<a[pnode][nid])
	   {
	       pnode= used[i];
	   }
   }
   return pnode;
}

var n = parseInt(readline());
var a = new Array();
for(var i=0;i<n;i++)
{
    var b = readline().split(' ');
	a[i]=new Array();
	for(var j=0;j<b.length;j++)
	{
	    a[i][j]=parseInt(b[j]);
	}
}
// check
var isOK = 1;
for(var i=0;i<n;i++)
{
	for(var j=i+1;j<n;j++)
	{
	    if(a[i][j]!=a[j][i] || a[i][j]==0)
		{
		    isOK=0;
			break;
		}
	}
}

// used: the list of ids which are used
var used = new Array();
used[0]=0;

// u[i]=1 -> node i is used.
var u = new Array();
for(var i=0;i<n;i++)
{
    u[i]=0;
}
u[0]=1;

if(isOK==0)
{
    print("NO");
}
else{
    var k=1;
    while(k<n)
    {
        // get the nearest node to node 0
	    var next_node = getNextNode();
		print(next_node);
		// get the parent node of next_node
		var pnode = getNearestNode(next_node);
		print(pnode);

		for(var i=0;i<used.length;i++)
		{
		    if(a[used[i]][pnode]+a[next_node][pnode]!=a[used[i]][next_node])
			{
			    isOK=0;
				break;
			}
		}
		if(isOK==1)
		{
		    used[used.length]=next_node;
		}
        else
	    {
	        break;
	    }
	    k++;
    }
    if(isOK==1)
    {
        print("YES");
    }
    else
    {
        print("NO");
    }
}

function getNextNode()
{
    var nd = -1;
	for(var i=0;i<n;i++)
	{
	    if(u[i]==0&&nd==-1)
		{
		    nd=i;
		}
		else if(u[i]==0&&nd!=-1)
		{
		    if(a[0][i]<a[0][nd])
			{
			    nd=i;
			}
		}
	}
	u[nd]=1;
	return nd;
}

function getNearestNode( nid )
{
   var pnode =used[0];
   for(var i=1;i<used.length;i++)
   {
       if(a[used[i]][nid]<a[pnode][nid])
	   {
	       pnode= used[i];
	   }
   }
   return pnode;
}