#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  char y[300][300], o[2], u[2];
  cin >> num;
  for (int i = 0; i < num; i++) {
    for (int j = 0; j < num; j++) cin >> y[i][j];
  }
  o[0] = y[0][0];
  u[0] = y[0][1];
  for (int i = 0; i < num; i++) {
    for (int j = 0; j < num; j++) {
      if (i == j || i + j + 1 == num) {
        if (o[0] == y[i][j] && y[i][j] <= 'z' && y[i][j] >= 'a')
          continue;
        else {
          cout << "NO";
          return 0;
        }
      } else {
        if (u[0] == y[i][j] && y[i][j] <= 'z' && y[i][j] >= 'a' && u[0] != o[0])
          continue;
        else {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
  return 0;
}
