#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp = 0;
  char arr[300][300];
  char a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  a = arr[n / 2][n / 2];
  b = arr[0][1];
  for (int i = 0; i < n; i++) {
    if (arr[i][i] != a || arr[i][n - (i + 1)] != a || arr[i][i] == b ||
        arr[i][n - (i + 1)] == b) {
      temp = 1;
      break;
    }
    for (int j = 0; j < n; j++) {
      if (i != j && j != (n - (i + 1))) {
        if (arr[i][j] != b) {
          temp = 1;
          break;
        }
      }
    }
  }
  if (temp == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
