#include <bits/stdc++.h>
int main() {
  char s[305][305], charD, charO;
  int i, j, flag, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  charD = s[0][0];
  charO = s[0][1];
  flag = 0;
  if (charD == charO)
    flag = 1;
  else {
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (i == j) {
          if (s[i][j] != charD) {
            flag = 1;
            break;
          }
        } else if (j == n - 1 - i) {
          if (s[i][j] != charD) {
            flag = 1;
            break;
          }
        } else {
          if (s[i][j] != charO) {
            flag = 1;
            break;
          }
        }
      }
      if (flag == 1) break;
    }
  }
  if (flag == 1)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
