#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char arr[n][n];
  set<int> st1, st2;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      cin >> arr[i][j];
      if (i == j || i + j == n - 1)
        st1.insert(arr[i][j]);
      else
        st2.insert(arr[i][j]);
    }
  if (st1.size() == 1 && st2.size() == 1 && *st1.begin() != *st2.begin())
    cout << "YES";
  else
    cout << "NO";
}
