#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n;
char buf[N];
int A[N][N];
vector<pair<int, int> > ones;
inline bool check(int x1, int y1, int x2, int y2) {
  if (x2 == x1 + 1 || y2 == y1 + 1) return 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i < x1 || i > x2 || j < y1 || j > y2)
        if (A[i][j] != 0) return 0;
      if (i > x1 && i < x2 && j > y1 && j < y2)
        if (A[i][j] != 4) return 0;
      if ((i == x1 || i == x2) && (j > y1 && j < y2))
        if (A[i][j] != 2) return 0;
      if ((i > x1 && i < x2) && (j == y1 || j == y2))
        if (A[i][j] != 2) return 0;
      if ((i == x1 || i == x2) && (j == y1 || j == y2))
        if (A[i][j] != 1) return 0;
    }
  }
  return 1;
  if (x1 + 2 == x2) {
    if (A[x1 + 1][y1 + 1] != 4 || A[x1 + 1][y2 - 1] != 4) return 0;
    if (y1 >= 0 && A[x1 + 1][y1] != 2 || y2 < n && A[x1 + 1][y2] != 2) return 0;
    for (int j = y1 + 1; j <= y2 - 1; j++) {
      if (A[x1 + 1][j] != 4) return 0;
      if (x1 >= 0 && A[x1][j] != 2) return 0;
      if (x2 < n && A[x2][j] != 2) return 0;
    }
    return 1;
  } else if (y1 + 2 == y2) {
    if (A[x1 + 1][y1 + 1] != 4 || A[x2 - 1][y1 + 1] != 4) return 0;
    if (x1 >= 0 && A[x1][y1 + 1] != 2 || x2 < n && A[x2][y1 + 1] != 2) return 0;
    for (int i = x1 + 1; i <= x2 - 1; i++) {
      if (A[i][y1 + 1] != 4) return 0;
      if (y1 >= 0 && A[i][y1] != 2) return 0;
      if (y2 < n && A[i][y2] != 2) return 0;
    }
    return 1;
  } else {
    if (A[x1 + 1][y1 + 1] != 3 || A[x2 - 1][y1 + 1] != 3) return 0;
    if (A[x2 - 1][y1 + 1] != 3 || A[x1 + 1][y2 - 1] != 3) return 0;
    for (int j = y1 + 1; j <= y2 - 1; j++) {
      if (j > y1 + 1 && j < y2 - 1 && A[x1 + 1][j] != 2) return 0;
      if (x1 >= 0 && A[x1][j] != 2) return 0;
      if (x2 < n && A[x2][j] != 2) return 0;
    }
    for (int i = x1 + 1; i <= x2 - 1; i++) {
      if (i > x1 + 1 && i < x2 - 1 && A[i][y1 + 1] != 2) return 0;
      if (y1 >= 0 && A[i][y1] != 2) return 0;
      if (y2 < n && A[i][y2] != 2) return 0;
    }
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  int maxd = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", buf);
    for (int j = 0; j < n; j++) {
      A[i][j] = buf[j] - '0';
      if (A[i][j] > maxd) maxd = A[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (A[i][j] == maxd) ones.push_back(make_pair(i, j));
  }
  int x1 = n, y1 = n, x2 = -1, y2 = -1;
  for (int i = 0; i < ones.size(); i++) {
    x1 = min(ones[i].first, x1);
    x2 = max(ones[i].first, x2);
    y1 = min(ones[i].second, y1);
    y2 = max(ones[i].second, y2);
  }
  if (check(x1 - 1, y1 - 1, x2 + 1, y2 + 1))
    puts("Yes");
  else
    puts("No");
  return 0;
}
