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