#include <bits/stdc++.h>
using namespace std;
const int oo = 1047483647, maxn = 1100;
int n, i, j, k, m, q, tot, w, now;
int a[maxn * maxn * 2], T[maxn * maxn], H[maxn * maxn], b[maxn * maxn * 2], vx,
    vy;
int f[maxn * maxn * 8], cover[maxn * maxn * 8];
int Read() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && (ch != '-'))
    ;
  bool neg = (ch == '-');
  if (ch == '-') ch = getchar();
  int v = 0;
  while (ch >= '0' && ch <= '9') v = v * 10 + ch - '0', ch = getchar();
  if (neg) v = -v;
  return v;
}
bool cmp(const int &x, const int &y) { return a[x] < a[y]; }
bool cmp2(const int &x, const int &y) { return T[x] < T[y]; }
void change(int p, int v) {
  f[p] = max(f[p], v);
  cover[p] = max(cover[p], v);
}
void put(int p) {
  change(p * 2, cover[p]);
  change(p * 2 + 1, cover[p]);
  cover[p] = 0;
}
int ask(int p, int x, int y, int l, int r, int v) {
  if (x != y && cover[p]) put(p);
  if (l <= x && y <= r) {
    int t = f[p];
    change(p, v);
    if (x != y) put(p);
    return t;
  }
  int mid = (x + y) / 2;
  int t1;
  if (r <= mid)
    t1 = ask(p * 2, x, mid, l, r, v);
  else if (l > mid)
    t1 = ask(p * 2 + 1, mid + 1, y, l, r, v);
  else {
    t1 = ask(p * 2, x, mid, l, r, v);
    int t2 = ask(p * 2 + 1, mid + 1, y, l, r, v);
    t1 = min(t1, t2);
  }
  f[p] = min(f[p * 2], f[p * 2 + 1]);
  return t1;
}
int main() {
  n = Read();
  vx = Read();
  vy = Read();
  for (i = 0; i <= n - 1; i++)
    for (j = 0; j <= n - 1; j++) {
      H[++tot] = Read();
      int dx, dy;
      int L = oo, R = -oo, tx = -oo;
      for (dx = 0; dx <= 1; dx++)
        for (dy = 0; dy <= 1; dy++) {
          int Rec = (i + dx) * vy - vx * (j + dy);
          int ER = (i + dx) * vx + (j + dy) * vy;
          L = min(L, Rec);
          R = max(R, Rec);
          tx = max(tx, ER);
        }
      a[++w] = L;
      a[++w] = R;
      T[tot] = tx;
    }
  for (i = 1; i <= w; i++) b[i] = i;
  sort(b + 1, b + w + 1, cmp);
  memset(cover, 0, sizeof cover);
  memset(f, 0, sizeof f);
  int last = -oo;
  for (i = 1; i <= w; i++) {
    if (a[b[i]] != last) now++;
    last = a[b[i]];
    a[b[i]] = now;
  }
  for (i = 1; i <= tot; i++) b[i] = i;
  sort(b + 1, b + tot + 1, cmp2);
  long long ans = 0;
  for (j = 1; j <= tot; j++) {
    i = b[j];
    int t = ask(1, 1, now, a[i + i - 1] + 1, a[i + i], H[i]);
    ans += max(H[i] - t, 0);
  }
  cout << ans;
  return 0;
}
