#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main(int argc, char *argv[]) {
  int T;
  scanf("%d", &T);
  for (int t = 0; t < T; ++t) {
    int N;
    scanf("%d", &N);
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d", &v[i]);
    }
    int count = 0;
    for (int i = 1; i < N; ++i) {
      if (v[i] < v[i - 1]) count++;
    }
    if (count == N - 1)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
