#include <bits/stdc++.h>
using namespace std;
void nandini() {
  long long int n, i, j, d = 0, e = 0;
  cin >> n;
  if (n == 1)
    cout << "YES";
  else {
    char a[n][n];
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        cin >> a[i][j];
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (a[i][j] == a[0][0] && (i + j == n - 1 || i == j))
          d++;
        else if (a[i][j] == a[0][1] && a[i][j] != a[0][0] && i + j != n - 1 &&
                 i != j)
          e++;
      }
    }
    if (d == 2 * n - 1 && (e == (n * n) - (2 * n) + 1))
      cout << "YES";
    else
      cout << "NO";
  }
}
int main() {
  long long int t = 1;
  while (t--) {
    nandini();
  }
  return 0;
}
