#include <bits/stdc++.h>
using namespace std;
int main() {
  char m[300][300];
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", m[i]);
  bool sw = true;
  char save = m[0][0];
  for (int i = 0, j = n - 1; i < n; i++, j--) {
    if (m[i][i] != save) {
      sw = false;
      break;
    }
    if (m[i][j] != save) {
      sw = false;
      break;
    }
  }
  char x = m[0][1];
  if (!sw)
    printf("NO");
  else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        if (i + j == n - 1) continue;
        if (m[i][j] == save) {
          sw = false;
          break;
        }
        if (m[i][j] != x) {
          sw = false;
          break;
        }
      }
    }
    if (sw)
      printf("YES");
    else
      printf("NO");
  }
  return 0;
}
