#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char temp;
  char arr[n][n];
  int count = 0;
  int flag = 0;
  int rem = (n * n) - ((2 * n) - 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  temp = arr[0][0];
  for (int i = 0; i < n; i++) {
    if (arr[i][i] == temp) {
      count++;
    }
    if (arr[i][n - 1 - i] == temp) {
      count++;
    }
  }
  temp = arr[0][1];
  if (count == 2 * n) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i != j || i != n - 1 - i) {
          if (arr[i][j] == temp) {
            flag++;
          }
        }
      }
    }
    if (flag == rem) {
      cout << "YES";
    } else {
      cout << "NO";
    }
  } else {
    cout << "NO";
  }
}
