#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  char a[n][n], c;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c;
      a[i][j] = c;
    }
  }
  int count = 0, c1 = 0;
  char x = a[0][0], y = a[0][1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j && a[i][j] == x)
        count++;
      else if ((i + j) == n - 1 && a[i][j] == x)
        count++;
      else if (a[i][j] == y && x != y)
        c1++;
    }
  }
  if (count == n * 2 - 1 && c1 == (n * n) - (n * 2 - 1))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
