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