#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
int mx[1100010 * 3], flag[1100010 * 3];
int first[1100010 * 2], a[1100010], b[1100010], c[1100010], h[1100010],
    id[1100010];
bool cmp(int u, int v) { return c[u] < c[v]; }
void update(int u, int L, int R, int st, int ed, int first) {
  if (L >= ed || R <= st) return;
  if (st <= L && R <= ed) return smax(mx[u], first), smax(flag[u], first);
  update((u << 1), L, L + R >> 1, st, ed, first);
  update(((u << 1) | 1), L + R >> 1, R, st, ed, first);
  flag[u] = max(mx[u], min(flag[(u << 1)], flag[((u << 1) | 1)]));
}
int calc(int u, int L, int R, int st, int ed) {
  if (L >= ed || R <= st) return 1e9;
  if (st <= L && R <= ed) return flag[u];
  return max(mx[u], min(calc((u << 1), L, L + R >> 1, st, ed),
                        calc(((u << 1) | 1), L + R >> 1, R, st, ed)));
}
int main() {
  int n, vx, vy, u;
  scanf("%d%d%d", &n, &vx, &vy);
  int nn = 0, nx = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &u);
      int st = 1e9, ed = -1e9, r = 1e9;
      for (int k = 0; k < 2; k++)
        for (int kk = 0; kk < 2; kk++) {
          int ii = i - k, jj = j - kk;
          smin(st, vy * ii - vx * jj);
          smax(ed, vy * ii - vx * jj);
          smin(r, vx * ii + vy * jj);
        }
      h[nn] = u, a[nn] = st, b[nn] = ed, c[nn] = r, id[nn] = nn;
      nn++;
      first[nx++] = st, first[nx++] = ed;
    }
  sort(first, first + nx);
  nx = unique(first, first + nx) - first;
  sort(id, id + nn, cmp);
  long long ans = 0;
  for (int k = 0; k < nn; k++) {
    int i = id[k];
    int st = lower_bound(first, first + nx, a[i]) - first;
    int ed = lower_bound(first, first + nx, b[i]) - first;
    int mid = calc(1, 0, nx, st, ed);
    if (mid < h[i]) {
      ans += h[i] - mid;
      update(1, 0, nx, st, ed, h[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
