#include <bits/stdc++.h>
using namespace std;
char a[305][305];
int main() {
  int n;
  cin >> n;
  string s[305];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < s[i].length(); j++) {
      a[i][j] = s[i][j];
    }
  }
  char l = a[0][0], h = a[0][n / 2];
  if (l == h) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j || i + j == n - 1) {
        if (a[i][j] != l) {
          cout << "NO";
          return 0;
        }
      } else {
        if (a[i][j] != h) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
}
