#include <bits/stdc++.h>
using namespace std;
const int MAX = 0x7fffffff;
const int INF = 0xfffffff;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, i, j, t, pos;
  cin >> t;
  while (t--) {
    cin >> n;
    int arr[n];
    pos = -1;
    for (i = 0; i < n; ++i) {
      cin >> arr[i];
      if (arr[i] == 1) pos = i;
    }
    bool q1 = true, q2 = true;
    for (i = 1; i < n; ++i) {
      q1 &= (arr[(pos - i + n) % n] == i + 1);
      q2 &= (arr[(pos + i + n) % n] == i + 1);
    }
    if (q1 || q2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
