/*
Почему ты смотришь v мой код?
плохо-плохо
=)
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdarg>
#include <cassert>
#include <climits>
#include <cstring>
#include <complex>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <bitset>
#include<stack>
using namespace std;
#define ll long long
#define ld long double
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_element((a).begin(), (a).end()))
#define maxe(a) (*max_element((a).begin(), (a).end()))
#define mini(a) ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a) ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define int long long
#define pb push_back
template<typename T> vector<T>& operator-- (vector<T>& v) { for (auto& i : v) --i; return v; }
template<typename T> vector<T>& operator++ (vector<T>& v) { for (auto& i : v) ++i; return v; }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { for (auto& i : v) is >> i; return is; }
template<typename T> ostream& operator<<(ostream& os, vector<T>& v) { for (auto& i : v) os << i << ' '; return os; }
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << p.first << ' ' << p.second; return os; }
template<typename T, typename U> pair<T, U> operator-(pair<T, U> a, pair<T, U> b) { return mp(a.first - b.first, a.second - b.second); }
template<typename T, typename U> pair<T, U> operator+(pair<T, U> a, pair<T, U> b) { return mp(a.first + b.first, a.second + b.second); }
template<typename T, typename U> void umin(T& a, U b) { if (a > b) a = b; }
template<typename T, typename U> void umax(T& a, U b) { if (a < b) a = b; }
long long a, b, c, e, f, g;
ll h[1000005];
ll h2[1000005];
ll h3[1000005];
bool fl = 0;
void rec(int c, int e, int f, int pos)
{
if (fl == 1) return;
if (pos == a + 1)
{
if (c == b - 1 && e == b && f == b + 1)
{
for (int i = 1; i <= a; i++)
{
cout << h[i] << " ";
}
cout << '\n';
fl = 1;
return;
}
return;
}
if (c + pos <= b - 1)
{
h[pos] = 1;
rec(c + pos, e, f, pos + 1);
}
if (e + pos <= b)
{
h[pos] = 2;
rec(c, e + pos, f, pos + 1);
}
if (f + pos <= b + 1)
{
h[pos] = 3;
rec(c, e, f + pos, pos + 1);
}
}
void solve()
{
cin >> a;
for (int i = 1; i <= a; i++)
{
cin >> h[i];
}
f = 0;
for (int i = 1; i <= a; i++)
{
for (int j = 1; j < a; j++)
{
if (h[j] > h[j + 1]) { swap(h[j], h[j + 1]); f++; }
}
}
if (f % 4 == 0)
{
cout << "YES\n";
}
else cout << "NO\n";
}
/*
5 6 54
1
3
2 1000 100
-1 1 1
-1 2 1000
100
1
L
1 2
1
R
2 1
2
LL
1 2 2
2
RR
2 2 1
2
LR
1 5 1
*/
signed main() {
int q;
q = 1;
cin >> q;
while (q != 0)
{
solve();
q--;
}
}
/*
0 4 10 16 28 43 0 -4 -10 -16 -28 -43
202 210 234 270 366 516 202 210 234 270 366 516
-1 3 9 15 27 42 1 -3 -9 -15 -27 -42
2252
154 154 162 162 174 174 186 186 210 210 240 240
154 162 174 186 210 240
x1 x2 x3 x4 x5 x6
154=x2*2
162=x1*2
162-154=(x1*2)-(x2*2)
8=2*x1+2*x2
8=2*(x1+x2)
4=x1-x2;
174-162=(x2*2)-(x3*2)
6=x2-x3;
40 56 48 40 80 56 80 48
40 48 56 80
1 5 9 21
64 48 48 96
x1-x2=4
x3-x2=4
x4-x3=12
0 4 10 16 28 43
1 7 9 10 19 37 73 145 289
17 33 65 129 257
13 19 31 55
2x-y=0;
1-2=0
bbccacbс
bbcacaa
aabbaa
yyyyxyyy = 14
xyyyyyyy
*/