#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
int n;
char a[5001][5001];
int met[301];
bool was[301];
int dif = 0;
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      cin >> a[i][j];
    }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      if (!(i == j || j == n - i + 1)) {
        if (a[i][j] == a[1][1] || a[i][j] == a[1][n]) {
          cout << "NO";
          return 0;
        }
        if (!was[a[i][j]]) ++dif;
        was[a[i][j]] = 1;
        if (dif == 2) {
          cout << "NO";
          return 0;
        }
        continue;
      }
      if (i == j) {
        ++met[a[i][j]];
        continue;
      }
      if (j == n - i + 1) ++met[a[i][j]];
    }
  if (met[a[1][1]] == n + n - 1)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
