#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n, A;
    cin >> n;
    vector<int> a, b;
    for (int i = (0); i < (n); i++) {
      cin >> A;
      a.push_back(A);
      b.push_back(A);
    }
    sort((b).begin(), (b).end());
    reverse((b).begin(), (b).end());
    if (a != b) {
      cout << "YES\n";
      continue;
    }
    map<int, int> dif;
    for (auto x : a) dif[x]++;
    int cant = 0;
    for (auto i : dif) cant++;
    cout << (cant == n ? "NO\n" : "YES\n");
  }
  return 0;
}
