#include <bits/stdc++.h>
using namespace std;
int t, x;
vector<pair<int, int>> v;
bool used, ans;
int hx, hy, col;
int main() {
  cin >> t;
  int n, m;
  while (t--) {
    cin >> n;
    ans = true;
    used = 0;
    for (int i = 1; i <= n; i++) {
      cin >> x;
      if (ans == true) {
        col = x;
        ans = false;
      }
      v.push_back(make_pair(x, i));
    }
    ans = true;
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < n; i++) {
      if (used == 0) {
        used = 1;
        hx = v[i].first;
        hy = v[i].second;
        continue;
      } else {
        int y = v[i].second;
        int x = v[i].first;
        if (y < hy)
          continue;
        else {
          if (x > col) {
            hx = x;
            hy = y;
            continue;
          } else {
            ans = false;
            cout << "NO" << endl;
            break;
          }
        }
      }
    }
    if (ans == true) cout << "YES" << endl;
    v.clear();
  }
  return 0;
}
