#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int a[n];
    long long int b[n];
    int pos = 1;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      b[i] = a[i];
    }
    sort(b, b + n);
    reverse(b, b + n);
    for (int i = 0; i < n; i++) {
      if (b[i] != a[i]) {
        pos = 0;
        break;
      }
      if (i != 0 && b[i] == b[i - 1]) pos = 0;
    }
    if (!pos)
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  }
}
