#include <bits/stdc++.h>
using namespace std;
const int N = 3e2 + 5, OO = 0x3f3f3f3f;
int n, cnt = 0, cnt2 = 0;
char a[N][N];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  char x = a[0][0];
  char y = a[0][1];
  for (int i = 0; i < n; i++) {
    if (a[i][i] == x && a[i][n - i - 1] == x) cnt++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == y) cnt2++;
    }
  }
  if (cnt2 == n * (n - 2) + 1 && cnt == n)
    puts("YES");
  else
    puts("NO");
  return 0;
}
