#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, arr[N];
int main() {
  int t, c;
  scanf("%d", &t);
  while (t--) {
    c = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%d", arr + i);
      if (i) c += (arr[i] < arr[i - 1]);
    }
    puts(c < n - 1 ? "YES" : "NO");
  }
  return 0;
}
