#include <bits/stdc++.h>
using namespace std;
char s[400][400];
bool a[27];
int nx[27];
int main() {
  int n;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    gets(s[i]);
    for (int j = 0; j < n; j++) a[s[i][j] - 'a'] = true, nx[s[i][j] - 'a']++;
  }
  int sm = 0;
  for (int i = 0; i < 26; i++) sm += a[i];
  if (sm != 2) {
    puts("NO");
    return 0;
  }
  for (int i = 0; i < n; i++)
    if (s[i][i] != s[0][0] || s[i][n - i - 1] != s[0][0]) {
      puts("NO");
      return 0;
    }
  if (nx[s[0][0] - 'a'] != 2 * n - 1) {
    puts("NO");
    return 0;
  }
  puts("YES");
}
