#include <bits/stdc++.h>
using namespace std;
char str[308][308];
int main() {
  int n, i, j;
  char ch1, ch2;
  bool f = true;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%s", str[i]);
  ch1 = str[0][0];
  ch2 = str[0][1];
  if (ch1 == ch2) f = false;
  for (i = 0; i < n && f; i++)
    for (j = 0; j < n && f; j++) {
      if (i == j || i + j == n - 1) {
        if (str[i][j] != ch1) f = false;
      } else {
        if (str[i][j] != ch2) f = false;
      }
    }
  if (f)
    puts("YES");
  else
    puts("NO");
  return 0;
}
