#include <bits/stdc++.h>
using namespace std;
long long extendedGcd(long long a, long long b, long long &x, long long &y);
void addEdge(vector<long long> adj[], long long u, long long v);
void DFSUtil(long long u, vector<long long> adj[], vector<bool> &visited);
void DFS(vector<long long> adj[], long long V, long long start = 0);
long long logg(long long x);
long long pw(long long x, long long y);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    if (v[0] == n) {
      cout << "NO" << '\n';
      continue;
    }
    vector<long long> ans;
    long long i = 0;
    while (i < n) {
      long long ele = v[i];
      long long j = i;
      long long mini = v[i];
      while (j < n && v[j] >= ele) {
        mini = min(mini, v[j]);
        j++;
      }
      ans.push_back(mini);
      i = j - 1;
      i++;
    }
    long long mini = -1;
    for (long long i = 0; i < ans.size() - 1; i++) mini = max(mini, ans[i]);
    if (mini <= v[n - 1])
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
  return 0;
}
long long pw(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1)
    return x;
  else {
    long long temp = pw(x, y / 2);
    if (y % 2 != 0)
      return ((((temp) * (temp))) * x);
    else
      return ((temp) * (temp));
  }
}
long long logg(long long x) {
  long long ans = 0;
  long long temp = 1;
  while (temp <= x) {
    temp *= 2;
    ans++;
  }
  if (temp > x) ans--;
  return ans;
}
long long extendedGcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = extendedGcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
void addEdge(vector<long long> adj[], long long u, long long v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
void DFSUtil(long long u, vector<long long> adj[], vector<bool> &visited) {
  visited[u] = true;
  cout << u << " ";
  for (long long i = 0; i < adj[u].size(); i++)
    if (visited[adj[u][i]] == false) DFSUtil(adj[u][i], adj, visited);
}
void DFS(vector<long long> adj[], long long V, long long start) {
  vector<bool> visited(V, false);
  for (long long u = start; u < V; u++)
    if (visited[u] == false) DFSUtil(u, adj, visited);
}
