#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  char s[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> s[i][j];
  int diag = s[0][0];
  int non_diag = s[0][1];
  if (diag == non_diag) {
    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 (s[i][j] != diag) {
          cout << "NO";
          return 0;
        }
      } else {
        if (s[i][j] != non_diag) {
          cout << "NO";
          return 0;
        }
      }
    }
  cout << "YES";
  return 0;
}
