#include <bits/stdc++.h> using namespace std; vector<string> split_string(string); /* * Complete the canModify function below. */ string canModify(vector<int> a) { // return "YES"; int cnt =0; for(int i = 1; i < a.size(); i++){ if(a[i] < a[i-1]) {cnt ++; if(a[i] < a[i-2]) a[i] = a[i-1]; else a[i-1]=a[i];} } if(cnt <= 1) return "YES"; return "NO"; } int main() { int n; int t; cin >> t; while(t--){ cin >> n; vector<int> a(n); for (int a_itr = 0; a_itr < n; a_itr++) { cin >> a[a_itr]; } string result = canModify(a); cout << result << endl;} return 0; }