#include <bits/stdc++.h>
using namespace std;
const double pi = acos(0.0) * 2.0;
template <class T>
inline T abs1(T a) {
  return a < 0 ? -a : a;
}
template <class T>
inline T max1(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T min1(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T gcd1(T a, T b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd1(b, a % b);
}
template <class T>
inline T lb(T num) {
  return num & (-num);
}
template <class T>
inline int bitnum(T num) {
  int ans = 0;
  while (num) {
    num -= lb(num);
    ans++;
  }
  return ans;
}
long long pow(long long n, long long m, long long mod = 0) {
  long long ans = 1;
  long long k = n;
  while (m) {
    if (m & 1) {
      ans *= k;
      if (mod) ans %= mod;
    }
    k *= k;
    if (mod) k %= mod;
    m >>= 1;
  }
  return ans;
}
const double eps = 1e-10;
inline int judge(double a, double b) {
  if (abs1(a - b) < eps)
    return 0;
  else if (a < b)
    return -1;
  return 1;
}
const int maxn = 2000;
int orig[maxn][maxn];
int n;
double vx, vy;
double dp[2][maxn * maxn / 3][3];
int ldp[2];
int main() {
  scanf("%d%lf%lf", &n, &vx, &vy);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &orig[i][j]);
  if (vx < 0) {
    vx = -vx;
    for (int i = 0; i < n / 2; i++)
      for (int j = 0; j < n; j++) swap(orig[i][j], orig[n - 1 - i][j]);
  }
  if (vy < 0) {
    vy = -vy;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n / 2; j++) swap(orig[i][j], orig[i][n - 1 - j]);
  }
  long long ans = 0;
  dp[0][0][1] = 1;
  dp[0][0][2] = orig[0][0];
  dp[0][1][1] = n + 1;
  double delta = pi / 4 - atan(vx / vy);
  delta = tan(delta) / 2;
  ans += orig[0][0];
  ldp[0] = 1;
  for (int i = 1; i < n; i++) {
    int link1 = 0;
    int now = i & 1, last = 1 - now;
    ldp[now] = 0;
    int add = 0;
    if (judge(delta, 1.0 / 2.0)) {
      dp[now][ldp[now]][1] = 0.5 - delta;
      dp[now][ldp[now]++][2] = orig[0][i];
    }
    while (judge(dp[last][link1][1], 0.5 + delta) == -1) {
      if (!judge(max1(dp[last][link1][2], double(orig[0][i])),
                 dp[now][ldp[now] - 1][2]))
        ldp[now]--;
      add = max1(add, orig[0][i] - (int)dp[last][link1][2]);
      dp[now][ldp[now]][1] = dp[last][link1][1] + 0.5 - delta;
      dp[now][ldp[now]++][2] = max1(dp[last][link1++][2], double(orig[0][i]));
    }
    if (!judge(max1(dp[last][link1][2], double(orig[0][i])),
               dp[now][ldp[now] - 1][2]))
      ldp[now]--;
    add = max1(add, orig[0][i] - (int)dp[last][link1][2]);
    dp[now][ldp[now]][1] = 1;
    dp[now][ldp[now]++][2] = max1(dp[last][link1][2], double(orig[0][i]));
    if (judge(dp[last][link1][1], 0.5 + delta) == 0) link1++;
    if (judge(delta, 1.0 / 2.0))
      ans += orig[0][i];
    else
      ans += add;
    for (int j = 1; j <= i; j++) {
      add = 0;
      while (judge(dp[last][link1][1], 0.5 + delta + j) == -1) {
        if (!judge(max1(dp[last][link1][2], double(orig[j][i - j])),
                   dp[now][ldp[now] - 1][2]))
          ldp[now]--;
        add = max1(add, orig[j][i - j] - (int)dp[last][link1][2]);
        dp[now][ldp[now]][1] = dp[last][link1][1] + 0.5 - delta;
        dp[now][ldp[now]++][2] =
            max1(dp[last][link1++][2], double(orig[j][i - j]));
      }
      if (!judge(max1(dp[last][link1][2], double(orig[j][i - j])),
                 dp[now][ldp[now] - 1][2]))
        ldp[now]--;
      add = max1(add, orig[j][i - j] - (int)dp[last][link1][2]);
      dp[now][ldp[now]][1] = j + 1;
      dp[now][ldp[now]++][2] = max1(dp[last][link1][2], double(orig[j][i - j]));
      if (judge(dp[last][link1][1], 0.5 + delta + j) == 0) link1++;
      ans += add;
    }
    dp[now][ldp[now]][1] = n + 1;
    dp[now][ldp[now]][2] = 0;
  }
  for (int i = 1; i < n; i++) {
    int link1 = 0;
    int now = i & 1, last = 1 - now;
    if ((n & 1) == 0) now = 1 - now, last = 1 - last;
    ldp[now] = 0;
    for (int j = i; j < n; j++) {
      int add = 0;
      while (judge(dp[last][link1][1], 0.5 + delta) != 1) link1++;
      while (judge(dp[last][link1][1], 0.5 + delta + j - i + 1) == -1) {
        if (max1(dp[last][link1][2], double(orig[j][n - 1 + i - j])) ==
            dp[now][ldp[now] - 1][2])
          ldp[now]--;
        add = max1(add, orig[j][n - 1 + i - j] - (int)dp[last][link1][2]);
        dp[now][ldp[now]][1] = dp[last][link1][1] - 0.5 - delta;
        dp[now][ldp[now]++][2] =
            max1(dp[last][link1++][2], double(orig[j][n - 1 + i - j]));
      }
      if (!judge(max1(dp[last][link1][2], double(orig[j][n - 1 + i - j])),
                 dp[now][ldp[now] - 1][2]))
        ldp[now]--;
      add = max1(add, orig[j][n - 1 + i - j] - (int)dp[last][link1][2]);
      dp[now][ldp[now]][1] = j + 1 - i;
      dp[now][ldp[now]++][2] =
          max1(dp[last][link1][2], double(orig[j][n - 1 + i - j]));
      if (judge(dp[last][link1][1], 0.5 + delta + j - i + 1) == 0) link1++;
      ans += add;
    }
  }
  cout << ans << endl;
  return 0;
}
