#include <bits/stdc++.h>
using namespace std;
int ara[205];
int main() {
  int line, n, i, j;
  cin >> line;
  while (line--) {
    cin >> n;
    for (i = 1; i <= n; i++) {
      cin >> ara[i];
    }
    bool flag = true;
    for (i = 2; i <= n; i++) {
      if (ara[i] == 1 && ara[i - 1] == n)
        continue;
      else if (ara[i] == n && ara[i - 1] == 1)
        continue;
      else {
        if (abs(ara[i] - ara[i - 1]) != 1) {
          flag = false;
          break;
        }
      }
    }
    if (ara[1] == 1 && ara[n] == n) {
    } else if (ara[1] == n && ara[n] == 1) {
    } else {
      if (abs(ara[n] - ara[1]) != 1) {
        flag = false;
      }
    }
    if (flag) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
