#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, temp, flag = 0;
    cin >> n;
    deque<long long int> a;
    for (i = 0; i < n; ++i) {
      cin >> temp;
      a.push_back(temp);
    }
    for (i = 0; i < n - 1; i++) {
      if (abs(a[i] - a[i + 1]) != 1) {
        if (abs(a[i] - a[i + 1]) != n - 1) {
          cout << "NO" << endl;
          flag = 1;
          break;
        }
      }
    }
    if (flag != 1) cout << "YES" << endl;
  }
  return 0;
}
