#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
const int MAXN = 299;
const int MOD = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long INF_64 = (1LL << 62);
const double eps = 1e-9;
bool no() {
  cout << "NO";
  exit(0);
}
int main() {
  char a[MAXN][MAXN];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  if (a[0][0] == a[0][1]) no();
  for (int i = 0; i < n; i++) {
    if (a[i][i] != a[0][0]) no();
    if (a[i][n - i - 1] != a[0][0]) no();
    for (int j = 0; j < n; j++)
      if (j != i && j != n - i - 1 && a[i][j] != a[0][1]) no();
  }
  cout << "YES";
}
