#include <bits/stdc++.h>
using namespace std;
long n;
string st;
set<char> set1, set2;
set<char>::iterator it;
char c1, c2;
bool bad() {
  it = set1.begin();
  c1 = (*it);
  it = set2.begin();
  c2 = (*it);
  return (c1 == c2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> st;
    for (int j = 0; j < st.size(); j++) {
      if (j == i || j + i == st.size() - 1)
        set2.insert(st[j]);
      else
        set1.insert(st[j]);
    }
  }
  if (set1.size() > 1 || set2.size() > 1 || bad())
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  cin.get();
  cin.get();
  return 0;
}
