#include <bits/stdc++.h>
using namespace std;
int a[205];
int main() {
  int T, n;
  cin >> T;
  for (int t = 0; t < T; t++) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      a[i]--;
    }
    if (n == 1) {
      puts("YES");
      continue;
    }
    bool x = true, y = true;
    for (int i = 1; i < n; i++) {
      if (a[i] != (a[i - 1] + 1) % n) {
        x = false;
        break;
      }
    }
    if ((a[n - 1] + 1) % n != a[0]) x = false;
    for (int i = 1; i < n; i++) {
      if (a[i] != (a[i - 1] - 1 + n) % n) {
        y = false;
        break;
      }
    }
    if ((a[n - 1] - 1 + n) % n != a[0]) y = false;
    if (x || y)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
