#include <bits/stdc++.h>
using namespace std;
void yesno(bool a) {
  if (a) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
}
long long power(long long x, long long n, long long m) {
  if (n == 0) return 1;
  long long u = power(x, n / 2, m);
  u = (u * u) % m;
  if (n % 2) u = (u * x) % m;
  return u;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int i;
    bool ok = 1;
    int arr[n];
    for (i = 0; i < n; i++) {
      cin >> arr[i];
    }
    int l = 0, r = n - 1;
    if (arr[0] == n || arr[n - 1] == 1) ok = 0;
    while (r - l + 1 > 2) {
      if (arr[l] > arr[r]) {
        ok = 0;
        break;
      }
      int pos = l + 1;
      while (pos < r && arr[pos] > arr[l]) pos++;
      pos--;
      int templ = arr[pos];
      arr[pos] = arr[l];
      l = pos;
      pos = r - 1;
      while (pos > l && arr[pos] < arr[r]) pos--;
      pos++;
      int tempr = arr[pos];
      arr[pos] = arr[r];
      r = pos;
      l++;
      r--;
    }
    yesno(ok);
  }
}
