#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, n, k;
  cin >> q;
  int a[300];
  for (int i = 0; i < q; i++) {
    cin >> n;
    k = 0;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
      if (j > 0 && abs(a[j - 1] - a[j]) > 1) k++;
    }
    if (abs(a[n - 1] - a[0]) > 1) k++;
    if (k > 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
