#include <bits/stdc++.h>
using namespace std;
long long i, j, n;
string s[305];
char c, d;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
  }
  c = s[1][0];
  d = s[1][1];
  if (c == d) {
    cout << "NO";
    return 0;
  }
  for (j = 1; j <= n; j++) {
    if (s[j][j - 1] != c) {
      cout << "NO";
      return 0;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < n; j++) {
      if (s[i][j] != d && i + j != n && i != j + 1) {
        cout << "NO";
        return 0;
      }
      if (s[i][j] != c && i + j == n) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
}
