#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n, i, j, k;
    cin >> n;
    long long a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    priority_queue<long long> pq;
    pq.push(a[0]);
    for (i = 1; i < n - 1; i++) {
      if (a[i] < pq.top()) pq.push(a[i]);
    }
    if (pq.top() < a[n - 1]) pq.pop();
    if (pq.top() < a[n - 1])
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
