#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char ch, c, w;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> ch;
      if (i == 0 && j == 0) {
        c = ch;
      } else if (i == 0 && j == 1) {
        w = ch;
      } else {
        if (c == w) {
          cout << "NO";
          return 0;
        }
        if (i == j || i + j == n - 1) {
          if (ch != c) {
            cout << "NO";
            return 0;
          }
        } else {
          if (ch != w) {
            cout << "NO";
            return 0;
          }
        }
      }
    }
  }
  cout << "YES";
}
