#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> v(n);
    for (long long int i = 0; i < (long long int)(v.size()); i++) cin >> v[i];
    map<long long int, long long int> m;
    long long int f = 0;
    for (long long int i = 0; i < (long long int)(n); i++) {
      m[v[i]]++;
      if (m[v[i]] > 1) f = 1;
    }
    vector<long long int> p = v;
    vector<long long int> q = v;
    sort(q.begin(), q.end());
    reverse(q.begin(), q.end());
    sort(v.begin(), v.end());
    if (p == v || f)
      cout << "YES"
           << "\n";
    else if (p == q)
      cout << "NO"
           << "\n";
    else
      cout << "YES"
           << "\n";
  }
}
