#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s[300];
  for (int i = 0; i < n; i++) cin >> s[i];
  char first = s[0][0];
  char second = s[0][1];
  bool ok = true;
  if (first == second) ok = false;
  for (int i = 0; i < n && ok; i++)
    if (s[i][i] != first || s[i][i] == second) ok = false;
  for (int i = 0; i < n && ok; i++)
    if (s[i][n - i - 1] != first || s[i][n - i - 1] == second) ok = false;
  for (int i = 0; i < n && ok; i++) {
    for (int j = 0; j < n && ok; j++) {
      if (i != j && j != n - i - 1) {
        if (s[i][j] != second || s[i][j] == first) ok = false;
      }
    }
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
