#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, r = 0, x;
    cin >> n;
    map<long long int, long long int> mp;
    cin >> x;
    mp[x] = 1;
    long long int k = x;
    for (i = 2; i <= n; i++) {
      cin >> x;
      if (x > k) {
        r = max(r, i);
      }
      mp[x] = i;
    }
    i = 1;
    while (i < k) {
      if (mp[i] > r) break;
      i++;
    }
    if (i == k)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
