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