#include <bits/stdc++.h>
using namespace std;
long long powr(long long m, long long n) {
  if (m == 1) return 1;
  if (n == 0) return 1;
  if (n == 1) return m % 1000000007;
  if (n % 2) {
    long long te = powr(m, n / 2);
    return (((te * te) % 1000000007) * (m % 1000000007)) % 1000000007;
  } else {
    long long te = powr(m, n / 2);
    return (te * te) % 1000000007;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  cin >> tc;
  int cs = 0;
  while (tc--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    for (int i = 1; i < n; i++)
      if (a[i] < a[i - 1]) cnt++;
    if (cnt == n - 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
