#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  cin >> T;
  for (long long t = 0; t < (long long)T; t++) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < (long long)n; i++) {
      cin >> v[i];
    }
    long long cnt1 = 0;
    long long cnt2 = 0;
    for (long long i = 0; i < (long long)n; i++) {
      if (v[i] == v[(i - 1 + n) % n] + 1) {
        cnt1++;
      }
      if (v[i] == v[(i + 1) % n] + 1) {
        cnt2++;
      }
    }
    if (cnt1 == n - 1 || cnt2 == n - 1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
