#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 36;
const long long maxx = 1e16;
const long long mod = 1e9 + 7;
const long long mod1 = 998244353;
long long a[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long pre = -1;
    bool x = false;
    long long mx = 0;
    for (int i = 1; i < n;) {
      long long j = i + 1;
      while (j < n && a[j] >= a[j - 1]) {
        j++;
      }
      j--;
      mx = a[i];
      break;
      i = j + 1;
    }
    if (mx > a[n]) {
      cout << "NO"
           << "\n";
    } else {
      cout << "YES"
           << "\n";
    }
  }
}
