#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 7;
const int base = 2e5 + 1;
const long long MAX = 1e6;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 3 * 1e5 + 147;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for (int i = (0); i < (n); ++i) scanf("%d", &v[i]);
    int cnt = 0;
    for (int i = (1); i < (n); ++i) {
      if (v[i] < v[i - 1]) cnt++;
    }
    if (cnt == n - 1)
      puts("NO");
    else
      puts("YES");
  }
  return 0;
}
