#include <bits/stdc++.h>
using namespace std;
long long n;
vector<string> arr;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string h;
    cin >> h;
    arr.push_back(h);
  }
  char x = arr[0][0];
  for (int i = 0; i < n; i++) {
    if (arr[i][i] != x) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (arr[i][n - i - 1] != x) {
      cout << "NO" << endl;
      return 0;
    }
  }
  char y = arr[0][1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j || n - i - 1 == j) continue;
      if (arr[i][j] != y) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  if (x == y)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
