#include <bits/stdc++.h>
using namespace std;
const int INF = 2 * int(1e9);
const long long INFll = 1ll * int(1e9) * int(1e9);
const int MOD = 1000000007;
template <typename T>
ostream& operator<<(ostream& out, pair<T, T>& a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T>
istream& operator>>(istream& in, pair<T, T>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<pair<T, T> > a) {
  for (int i = 0; i < a.size(); ++i) out << a[i] << endl;
  return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
  for (int i = 0; i < a.size(); ++i) in >> a[i];
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> a) {
  for (int i = 0; i < a.size(); ++i)
    if (i == a.size() - 1)
      out << a[i];
    else
      out << a[i] << " ";
  return out;
}
vector<string> fill(int n, int x1, int y1, int x2, int y2) {
  vector<string> res(n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) res[i] += '0';
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (x1 <= i && i <= x2 && y1 <= j && j <= y2)
        res[i][j] = '4';
      else if (x1 <= i && i <= x2 && (j == y1 - 1 || j == y2 + 1))
        res[i][j] = '2';
      else if (y1 <= j && j <= y2 && (i == x1 - 1 || i == x2 + 1))
        res[i][j] = '2';
      else if (i == x1 - 1 && j == y1 - 1 || i == x1 - 1 && j == y2 + 1 ||
               i == x2 + 1 && j == y1 - 1 || i == x2 + 1 && j == y2 + 1)
        res[i][j] = '1';
    }
  return res;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<string> a(n);
  cin >> a;
  pair<int, int> x, y;
  for (int i = n - 1; i >= 0; --i)
    for (int j = n - 1; j >= 0; --j)
      if (a[i][j] == '4') x = make_pair(i, j);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (a[i][j] == '4') y = make_pair(i, j);
  vector<string> b = fill(n, x.first, x.second, y.first, y.second);
  if (a == b)
    cout << "Yes";
  else
    cout << "No";
  if (0)
    cerr << fixed << setprecision(0)
         << "TIME = " << clock() / (long double)CLOCKS_PER_SEC * 1000 << "\n";
  return 0;
}
