#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
string solve() {
  int n;
  cin >> n;
  vector<int> nums(n, 0);
  for (int i = 0; i < n; i++) cin >> nums[i];
  stack<int> s;
  for (int i = 0; i < n; i++) {
    if (s.empty()) {
      s.push(nums[i]);
    } else {
      int val = INT_MAX;
      while (!s.empty() and s.top() < nums[i]) {
        val = s.top();
        s.pop();
      }
      s.push(min(val, nums[i]));
    }
  }
  if (s.size() == 1) return "YES";
  return "NO";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    cout << solve() << endl;
  }
  return 0;
}
