#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 10;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, jav = 0;
    cin >> n;
    vector<long long> v, vans;
    set<long long> se;
    long long dp[n + 5];
    for (long long i = 0; i < n; i++) {
      long long s;
      cin >> s;
      dp[i] = s;
      v.push_back(s);
      se.insert(s);
    }
    for (long long i = n - 1; i >= 0; i--) vans.push_back(dp[i]);
    sort(v.begin(), v.end());
    for (long long i = 0; i < n; i++)
      if (v[i] != vans[i]) {
        jav = 1;
      }
    if ((long long)se.size() != n) jav = 1;
    if (jav == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
