#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1300 * 1000 + 7;
const int SS = 1 << 20;
const int INF = 1000 * 1000 * 1000 + 7;
int minn[MAXN], t[MAXN];
int n, m;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> t[i];
    }
    bool res = false;
    int poprz;
    if (t[1] < t[n]) res = true;
    for (int i = 2; i < n; i++) {
      if (t[1] < t[i] && t[i] < t[n]) res = true;
    }
    if (res == false)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
  return 0;
}
