#include <bits/stdc++.h>
using namespace std;
int ROW[] = {+1, -1, +0, +0};
int COL[] = {+0, +0, +1, -1};
int X[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int Y[] = {-1, +1, +0, +0, +1, +1, -1, -1};
int KX[] = {-2, -2, -1, -1, 1, 1, 2, 2};
int KY[] = {-1, 1, -2, 2, -2, 2, -1, 1};
void fastscan(int& number) {
  bool negative = false;
  int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }
int LCM(int a, int b) { return a * (b / GCD(a, b)); }
bool CMP(int a, int b) { return a > b; }
int main() {
  int t, ca = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 1];
    set<int> st;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      st.insert(a[i]);
    }
    reverse(a, a + n);
    if (st.size() < n)
      cout << "YES" << endl;
    else {
      bool ok = 1;
      for (int i = 1; i < n; i++)
        if (a[i] <= a[i - 1]) ok = 0;
      if (ok)
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    }
  }
END:
  return 0;
}
