#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long power(long long first, unsigned long long second,
                unsigned long long m) {
  if (second == 0) return 1;
  long long p = power(first, second / 2, m) % m;
  p = (p * p) % m;
  return (second % 2 == 0) ? p : (first * p) % m;
}
long long modInverse(long long a, long long m) {
  { return power(a, m - 2, m); }
}
const long long maxn = 500003;
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  set<long long> s;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n - 1; i++) {
    if (a[i] <= a[i + 1]) {
      cout << "YES"
           << "\n";
      return;
    }
    s.insert(a[i]);
  }
  s.insert(a[n - 1]);
  if (s.size() == n) {
    cout << "NO"
         << "\n";
    return;
  }
  cout << "YES"
       << "\n";
}
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long ter;
  cin >> ter;
  while (ter--) {
    solve();
  }
  return 0;
}
