#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    int a[50050];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    bool f = 0;
    for (int i = 0; i < n - 1; i++) {
      if (a[i] <= a[i + 1]) f = 1;
    }
    if (f)
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
}
