#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1000000007;
const char nl = '\n';
const long long MX = 100001;
long long powi(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = (res * x) % MOD;
    x = (x * x) % MOD;
    n >>= 1;
  }
  return res;
}
bool isPowerOfTwo(long long n) {
  if (n == 0) return 0;
  while (n != 1) {
    if (n % 2 != 0) return 0;
    n = n / 2;
  }
  return 1;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
long long sq(long long x) {
  long long k = sqrt(x);
  while (k * k < x) k++;
  while (k * k > x) k--;
  return k;
}
bool validpoint(long long i, long long j, long long r, long long c) {
  if ((i >= 0 && i < r) && (j >= 0 && j < c))
    return true;
  else
    return false;
}
bool check(vector<string>& v, long long r, long long c, long long i,
           long long j) {
  long long tp[4][2] = {{i + 1, j}, {i, j + 1}, {i - 1, j}, {i, j - 1}};
  for (long long i = 0; i < (4); i++) {
    long long ni = tp[i][0];
    long long nj = tp[i][1];
    if (validpoint(ni, nj, r, c) && v[ni][nj] == 'S') return true;
  }
  return false;
}
long long perfectCube(long long N) {
  long long cube_root;
  cube_root = round(cbrt(N));
  if (cube_root * cube_root * cube_root == N) {
    return 1;
  } else {
    return -1;
  }
}
long long formula(long long n) { return n * (n + 1) / 2; }
void solve() {
  long long n;
  cin >> n;
  set<long long> second;
  vector<long long> a;
  for (long long i = 0; i < (n); i++) {
    long long k;
    cin >> k;
    a.push_back(k);
    second.insert(k);
  }
  long long tp = second.size();
  long long rs = tp * (tp - 1) / 2;
  long long ms = n * (n - 1) / 2 - 1;
  if (rs <= ms) {
    cout << "YES"
         << "\n";
    return;
  }
  vector<long long> b;
  b = a;
  sort(b.begin(), b.end(), greater<long long>());
  if (b == a)
    cout << "NO"
         << "\n";
  else
    cout << "YES"
         << "\n";
}
long long z = 0;
bool check(long long mid, long long index) {
  long long x;
  long long y;
  cout << "?"
       << " " << index + 1 << "\n";
  cout.flush();
  cin >> x;
  cout << "?"
       << " " << index - 1 << "\n";
  cout.flush();
  cin >> y;
  if (x > mid && y > mid)
    return true;
  else {
    if (y > x)
      z = -1;
    else if (x > y)
      z = 1;
    return false;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
