#include <bits/stdc++.h> using namespace std; int n, a[10000]; string canModify() { bool used = false; for (int i = 1; i < n; i++) { if (a[i] < a[i-1]) { if (used) return "NO"; if (i > 1 && a[i] < a[i-2]) { a[i] = a[i-1]; } used = true; } } return "YES"; } int main() { int T; cin >> T; while (T--) { cin >> n; for (int i =0; i < n; i++) cin >> a[i]; cout << canModify() << endl; } return 0; }