#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int flag = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i];
      if (mp[a[i]] == 1) {
        flag = 1;
      } else {
        mp[a[i]] = 1;
      }
    }
    if (n == 1) {
      cout << "YES" << endl;
      continue;
    }
    sort(b, b + n, greater<int>());
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
