#include <bits/stdc++.h>
using namespace std;
int t, n;
int fwk[500005];
bool vis[500005], yes = 0;
void solve() {
cin >> n; yes = 0;
for(int i=1;i<=n;i++) vis[i] = 0;
int i = 1;
vector<pair<int, int>> vec(n);
for(auto &e:vec) {
cin >> e.first; e.second = i++;
if(vis[e.first]) {yes = 1;}
vis[e.first] = 1;
}
if(yes) {cout << "YES\n"; return ;}
sort(vec.rbegin(), vec.rend());
bool res=0;
for(auto e:vec) {
for(int cx=e.second;cx;cx-=cx&-cx)
res ^= fwk[cx];
for(int cx=e.second;cx<=n;cx+=cx&-cx)
fwk[cx] ^= 1;
}
for(int i=1;i<=n;i++) fwk[i] = 0;
cout << (res ? "NO\n" : "YES\n");
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
cin>>t;
while(t--) solve();
}
17A - Noldbach problem | 1350A - Orac and Factors |
1373A - Donut Shops | 26A - Almost Prime |
1656E - Equal Tree Sums | 1656B - Subtract Operation |
1656A - Good Pairs | 1367A - Short Substrings |
87A - Trains | 664A - Complicated GCD |
1635D - Infinite Set | 1462A - Favorite Sequence |
1445B - Elimination | 1656C - Make Equal With Mod |
567A - Lineland Mail | 1553A - Digits Sum |
1359B - New Theatre Square | 766A - Mahmoud and Longest Uncommon Subsequence |
701B - Cells Not Under Attack | 702A - Maximum Increase |
1656D - K-good | 1426A - Floor Number |
876A - Trip For Meal | 1326B - Maximums |
1635C - Differential Sorting | 961A - Tetris |
1635B - Avoid Local Maximums | 20A - BerOS file system |
1637A - Sorting Parts | 509A - Maximum in Table |