#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t1, n;
  cin >> t1;
  while (t1--) {
    cin >> n;
    int a[n];
    stack<int> s;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (s.empty())
        s.push(a[i]);
      else {
        int f = s.top();
        if (a[i] < f)
          s.push(a[i]);
        else {
          while (s.size() && a[i] > s.top()) {
            f = s.top();
            s.pop();
          }
          s.push(f);
        }
      }
    }
    cout << (s.size() == 1 ? "YES" : "NO") << endl;
  }
}
