#include <bits/stdc++.h>
namespace {
template <typename T1, typename T2>
std::istream& operator>>(std::istream& input, std::pair<T1, T2>& p) {
  return input >> p.first >> p.second;
}
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& output, const std::pair<T1, T2>& p) {
  return output << p.first << ' ' << p.second;
}
template <typename T>
std::istream& operator>>(std::istream& input, std::vector<T>& v) {
  for (T& x : v) input >> x;
  return input;
}
template <typename T>
std::ostream& operator<<(std::ostream& output, const std::vector<T>& v) {
  if (size_t n = v.size(); n > 0) {
    auto it = v.cbegin();
    for (output << *it++; --n > 0; output << ' ' << *it++)
      ;
  }
  return output;
}
template <typename T>
void print(const T& v) {
  std::cout << v << '\n';
}
void print(bool v) {
  constexpr const char* s[2] = {"NO", "YES"};
  std::cout << s[v] << '\n';
}
template <typename... T>
void answer(T&&... args) {
  (print(std::forward<T>(args)), ...);
}
template <typename T>
void minimize(T& a, T b) {
  if (a > b) a = b;
}
template <typename T, typename... U>
void minimize(T& a, U&&... args) {
  (minimize(a, std::forward<U>(args)), ...);
}
template <typename T>
void maximize(T& a, T b) {
  if (a < b) a = b;
}
template <typename T, typename... U>
void maximize(T& a, U&&... args) {
  (maximize(a, std::forward<U>(args)), ...);
}
template <typename T, typename U = T>
std::vector<U> prefix_sums(const std::vector<T>& v) {
  std::vector<U> ps;
  if (const size_t n = v.size(); n > 0) {
    ps.resize(n);
    U prefix_sum = 0;
    for (size_t i = 0; i < n; ++i) {
      prefix_sum += v[i];
      ps[i] = prefix_sum;
    }
  }
  return ps;
}
template <typename T, typename U = T>
std::vector<U> suffix_sums(const std::vector<T>& v) {
  std::vector<U> ss;
  if (const size_t n = v.size(); n > 0) {
    ss.resize(n);
    U suffix_sum = 0;
    for (size_t i = n - 1; ~i; --i) {
      suffix_sum += v[i];
      ss[i] = suffix_sum;
    }
  }
  return ss;
}
template <typename T>
std::vector<unsigned> frequency_map(size_t size, const std::vector<T>& v) {
  std::vector<unsigned> f(size);
  for (const T x : v) ++f[x];
  return f;
}
template <typename T>
std::map<T, unsigned> frequency_map(const std::vector<T>& v) {
  std::map<T, unsigned> f;
  for (const T x : v) ++f[x];
  return f;
}
}  // namespace
void solve(const std::vector<unsigned>& a) {
  const size_t n = a.size();
  unsigned x = a[0];
  for (size_t i = 1; i < n; ++i) {
    if (a[i] >= x) return answer(true);
    minimize(x, a[i]);
  }
  answer(false);
}
void test_case() {
  size_t n;
  std::cin >> n;
  std::vector<unsigned> a(n);
  std::cin >> a;
  solve(a);
}
int main() {
  size_t t = 1;
  std::cin >> t;
  while (t-- > 0) test_case();
  return 0;
}
