#include <bits/stdc++.h>
using namespace std;
long long n;
char ar[1000][1000];
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> ar[i][j];
    }
  }
  for (long long i = 0; i < n; i++)
    if (ar[i][i] != ar[0][0] || ar[n - i - 1][i] != ar[0][0]) {
      cout << "NO";
      return 0;
    }
  char ch = ar[0][1];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (i != j && n - i - 1 != j &&
          (ar[i][j] != ar[0][1] || ar[i][j] == ar[0][0])) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
