#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  char a[300][300];
  bool flag = true;
  cin >> n;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) cin >> a[i][j];
  if (a[0][0] == a[0][1]) flag = false;
  for (i = 1; i < n; i++) {
    if ((a[i][i] != a[i - 1][i - 1]) || (a[i][n - 1 - i] != a[i - 1][n - i])) {
      flag = false;
      break;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if ((i == j) || (i + j == n - 1)) continue;
      if (a[i][j] != a[0][1]) {
        flag = false;
        break;
      }
    }
  }
  if (flag == true)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
