#include <bits/stdc++.h>
using namespace std;
int T, n, top;
int a[300100], Stack[300100];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    Stack[top = 1] = a[1];
    for (int i = 2; i <= n; i++) {
      if (a[i] > Stack[1]) {
        top = 1;
      }
      if (a[i] > Stack[top]) continue;
      Stack[++top] = a[i];
    }
    if (top == 1)
      puts("YES");
    else
      puts("NO");
  }
}
