#include <bits/stdc++.h>
using namespace std;
char c[305][305];
int main() {
  int n;
  cin >> n;
  char x = '.';
  bool b = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c[i][j];
      if (i == j) {
        if (x == '.') {
          x = c[i][j];
          c[i][j] = '.';
        } else if (x != c[i][j]) {
          b = 1;
        } else
          c[i][j] = '.';
      }
    }
  }
  if (b) {
    cout << "NO" << endl;
    return 0;
  }
  int idx = 0;
  for (int j = n - 1; j > -1; j--, idx++) {
    if (c[idx][j] != x && c[idx][j] != '.') {
      cout << "NO" << endl;
      return 0;
    } else if (c[idx][j] == x)
      c[idx][j] = '.';
  }
  char cd = '.';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (cd == '.' && c[i][j] != x && c[i][j] != '.') {
        cd = c[i][j];
      } else if (c[i][j] != '.' && cd != c[i][j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
