#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<char>> v(0);
  for (int i = 0; i < n; i++) {
    vector<char> vm(n);
    for (int j = 0; j < n; j++) {
      cin >> vm[j];
    }
    v.push_back(vm);
    vm.clear();
  }
  for (int k = 0; k < n - 1; k++) {
    if (v[k][k] != v[k + 1][k + 1]) {
      cout << "NO";
      return 0;
    }
    if (v[k][n - 1 - k] != v[k + 1][n - 2 - k]) {
      cout << "NO";
      return 0;
    }
  }
  for (int l = 0; l < n; l++) {
    for (int m = 0; m < n; m++) {
      if ((l != m && l + m != (n - 1)) && v[l][m] != v[0][1]) {
        cout << "NO";
        return 0;
      }
    }
  }
  if (v[1][0] == v[0][0]) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
