#include <bits/stdc++.h>
using namespace std;
char a[305][305];
int main() {
  int n, i, j;
  int v = 1;
  scanf("%d", &n);
  set<char> s;
  for (i = 0; i < n; i++) {
    scanf("%s", &a[i]);
    for (j = 0; j < n; j++) s.insert(a[i][j]);
  }
  if (s.size() != 2) v = 0;
  char cur = a[0][0];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      if (i == j) {
        if (a[i][j] != cur) v = 0;
      } else if (i + j == n - 1) {
        if (a[i][j] != cur) v = 0;
      } else if (a[i][j] == cur)
        v = 0;
    }
  if (v)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
