#include <bits/stdc++.h>
using namespace std;
int n;
char pos[310][310];
bool deal() {
  char x = pos[0][0];
  if (pos[0][0] == pos[0][1]) return 0;
  for (int i = 0; i < n; i++)
    if (x != pos[i][i]) return 0;
  for (int i = 0; i < n; i++)
    if (x != pos[i][n - 1 - i]) return 0;
  x = pos[0][1];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j || j == n - 1 - i) continue;
      if (x != pos[i][j]) return 0;
    }
  return 1;
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) scanf("%s", &pos[i]);
    if (deal())
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
