#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
vector<int> md, rel;
void relax(int idx, int l, int r) {
  if (rel[idx]) {
    md[idx] = max(md[idx], rel[idx]);
    if (l != r) {
      rel[idx << 1] = max(rel[idx << 1], rel[idx]);
      rel[idx << 1 | 1] = max(rel[idx << 1 | 1], rel[idx]);
    }
    rel[idx] = 0;
  }
}
int get(int idx, int l, int r, int a, int b) {
  relax(idx, l, r);
  if (b < l || r < a) return INF;
  if (a <= l && r <= b) return md[idx];
  int mid = (l + r) >> 1;
  return min(get(idx << 1, l, mid, a, b), get(idx << 1 | 1, mid + 1, r, a, b));
}
void update(int idx, int l, int r, int a, int b, int val) {
  relax(idx, l, r);
  if (b < l || r < a) return;
  if (a <= l && r <= b) {
    rel[idx] = val;
    return relax(idx, l, r);
  }
  int mid = (l + r) >> 1;
  update(idx << 1, l, mid, a, b, val);
  update(idx << 1 | 1, mid + 1, r, a, b, val);
  md[idx] = min(md[idx << 1], md[idx << 1 | 1]);
}
int a[1100][1100], l[1100][1100], r[1100][1100], h[1100][1100];
int main() {
  int n, vx, vy;
  cin >> n >> vx >> vy;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) scanf("%d", &a[i][j]);
  vector<int> xs;
  xs.reserve(n * n * 2);
  vector<pair<int, pair<int, int> > > e;
  e.reserve(n * n);
  for (int x = 0; x < (int)(n); x++)
    for (int y = 0; y < (int)(n); y++) {
      l[x][y] = +INF;
      r[x][y] = -INF;
      h[x][y] = +INF;
      for (int dx = 0; dx < (int)(2); dx++)
        for (int dy = 0; dy < (int)(2); dy++) {
          l[x][y] = min(l[x][y], (x + dx) * vy - (y + dy) * vx);
          r[x][y] = max(r[x][y], (x + dx) * vy - (y + dy) * vx);
          h[x][y] = min(h[x][y], (x + dx) * vx + (y + dy) * vy);
        }
      xs.push_back(l[x][y]);
      xs.push_back(r[x][y]);
      e.push_back(make_pair(h[x][y], make_pair(x, y)));
    }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  sort(e.begin(), e.end());
  md.assign(xs.size() * 4, 0);
  rel.assign(xs.size() * 4, 0);
  long long ans = 0;
  for (int i = 0; i < (int)(e.size()); i++) {
    int x = e[i].second.first;
    int y = e[i].second.second;
    int lf = int(lower_bound(xs.begin(), xs.end(), l[x][y]) - xs.begin());
    int rg = int(lower_bound(xs.begin(), xs.end(), r[x][y]) - xs.begin()) - 1;
    int h = get(1, 0, (int)xs.size() - 1, lf, rg);
    if (h < a[x][y]) {
      ans += a[x][y] - h;
      update(1, 0, (int)xs.size() - 1, lf, rg, a[x][y]);
    }
  }
  cout << ans << endl;
  return 0;
}
