#include <bits/stdc++.h>
using namespace std;
const int MaxN = 300;
char s[MaxN][MaxN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  char one = s[0][0];
  char two = s[0][1];
  if (one == two) {
    printf("NO");
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j || i == n - j - 1) {
        if (s[i][j] != one) {
          printf("NO");
          return 0;
        }
      } else {
        if (s[i][j] != two) {
          printf("NO");
          return 0;
        }
      }
    }
  printf("YES");
}
