#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char c[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cin >> c[i][j];
  }
  int a[26] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a[c[i][j] - 'a']++;
    }
  }
  int cnt = 1, flag = 0;
  for (int i = 1, j = 1; i < n, j < n; i++, j++) {
    if (c[i][j] == c[0][0])
      cnt++;
    else
      flag = 1;
  }
  for (int i = 0, j = n - 1; i < n, j >= 0; i++, j--) {
    if (c[i][j] == c[0][0])
      cnt++;
    else
      flag = 1;
  }
  if (flag)
    cout << "NO";
  else {
    int fl = 0;
    for (int i = 0; i < 26; i++) {
      if (i + 'a' != c[0][0] && a[i] > 0) {
        if (a[i] == (n * n) - cnt + 1) {
          cout << "YES";
          fl = 1;
          break;
        } else {
          cout << "NO";
          fl = 1;
          break;
        }
      }
    }
    if (fl == 0) cout << "NO";
  }
}
