#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mx = 3e5 + 9;
int n;
int a[mx];
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    if (a[1] == 1 or a[n] == n) {
      cout << "YES" << endl;
      continue;
    }
    if (a[1] == n or a[n] == 1) {
      cout << "NO" << endl;
      continue;
    }
    if (a[1] > a[n]) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl;
  }
}
