#include <bits/stdc++.h> #ifndef dbg #define dbg(...) #endif #define all(x) begin(x), end(x) #define rsz(...) resize(__VA_ARGS__) #define psh(...) push_back(__VA_ARGS__) #define emp(...) emplace_back(__VA_ARGS__) #define prt(...) print(cout, __VA_ARGS__) #define dmp(...) print(cerr, #__VA_ARGS__, '=', __VA_ARGS__) #define dprt(...) dbg(print(cerr,__VA_ARGS__)) #define ddmp(...) dbg(dmp(__VA_ARGS__)) using namespace std;using ll=long long; template<typename t>void print(ostream& os, const t& a){os<<a<<'\n';} template<typename t, typename... A>void print (ostream& os, const t& a, A&&... b){os<<a<<' ';print(os, b...);} template<typename t>using V=vector<t>; inline bool check (V< int >& a) { for (int i = 0; i < (int)a.size() - 1; ++i) if (a[i + 1] < a[i]) return false; return true; } string canModify(vector<int> a) { /* * Write your code here. */ int cnt = 0; for (int i = 0; i < (int)a.size() - 1; ++i) if (a[i + 1] < a[i]) { int tmp = a[i]; a[i] = a[i + 1]; if (check(a)) return "YES"; ddmp(tmp); a[i] = tmp; a[i + 1] = a[i]; if (check(a)) return "YES"; return "NO"; } return "YES"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { int n; cin >> n; V< int > tb(n); for (int& i : tb) cin >> i; prt(canModify(tb)); } }