#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, sumx = 0, sumy = 0;
  char test1, test2;
  string s;
  cin >> x;
  for (int i = 0, j = x - 1; i < x; i++, j--) {
    cin >> s;
    if (i == 0) {
      test1 = s[0];
      test2 = s[1];
    }
    if (s[i] == test1) sumx++;
    if (s[j] == test1) sumx++;
    if (i == j && s[i] == test1) sumx--;
    for (int z = 0; z < s.size(); z++) {
      if (s[z] == test2) sumy++;
    }
  }
  if (sumx == ((x * 2) - 1) && sumy == ((x * x) - sumx))
    cout << "YES" << endl;
  else {
    cout << "NO" << endl;
  }
  return 0;
}
