#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char arr[301][301];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  char first = arr[0][0];
  char second = arr[1][0];
  bool is = true;
  if (first == second) is = false;
  if (is) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j == i || j == n - 1 - i) {
          if (arr[i][j] != first) {
            is = false;
            break;
          }
          if (arr[i][j] != first) {
            is = false;
            break;
          }
        } else if (arr[i][j] != second) {
          is = false;
          break;
        }
      }
    }
  }
  cout << (is ? "YES" : "NO");
  return 0;
}
