#include <bits/stdc++.h>
using namespace std;
const double e = 2.718281828;
void ox90() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
}
int main() {
  char G[300][300];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> G[i];
  for (int i = 0; i < n; i++) {
    if (G[i][i] == G[i][n - 1 - i] and G[0][0] == G[i][i] and
        G[0][n - 1] == G[i][n - 1 - i])
      ;
    else {
      printf("NO\n");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j or j == n - i - 1) continue;
      if (G[i][j] != G[1][0] or G[0][0] == G[i][j]) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
}
