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