#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    int sum = 0;
    for (int i = 1; i < n; i++) {
      sum += arr[i] - arr[i - 1];
    }
    if (sum < 0 || arr[0] == n && arr[n - 1] == 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
