#include <bits/stdc++.h>
using namespace std;
int oo = (1e9) + 7;
long long oo2 = 1ll * oo * oo;
int main() {
  int q, n;
  cin >> q;
  while (q--) {
    scanf("%d", &n);
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &v[i]);
      v[i]--;
    }
    bool ok1 = true, ok2 = true;
    for (int i = 0; i + 1 < n; i++) {
      ok1 &= ((v[i] + 1) % n == v[i + 1]);
      ok2 &= ((v[i + 1] + 1) % n == v[i]);
    }
    ok1 || ok2 ? puts("YES") : puts("NO");
  }
  return 0;
}
