#include <bits/stdc++.h>
char a[350][350];
int b[150];
using namespace std;
int main() {
  memset(b, 0, sizeof(b));
  int m, i, j, e, f, g, q = 0, p = 0, s = 0;
  cin >> m;
  getchar();
  g = 1;
  e = 0;
  f = m - 1;
  for (i = 0; i < m; i++) {
    cin >> a[i];
    if (a[i][e] != a[0][0] || a[i][f] != a[0][0]) g = 0;
    e++;
    f--;
  }
  for (i = 0; i < m; i++)
    for (j = 0; j < m; j++) {
      if (a[i][j] == a[0][0]) p++;
      if (a[i][j] == a[0][1] && a[i][j] != a[0][0]) q++;
    }
  if ((2 * m - 1) == p && (m * m - 2 * m + 1) == q) s = 1;
  if (!s || !g)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
