import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 10^^9 + 7;
immutable int M = 62;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto X = s[1].to!long;
    auto D = s[2].to!long;
    auto A = new long[](N);
    A[0] = X;
    foreach (i; 0..N-1) A[i + 1] = A[i] + D;

    if (D == 0) {
        if (X == 0) {
            writeln(0);
        } else {
            powmod(2, N, MOD).writeln;
        }
        return;
    }

    if (D < 0) A = A.dup.reverse.array, D *= -1, X = A.front;

    long mx = 1L * N * (N - 1) / 2;
    long mn = mx;

    Tuple!(long, long)[][long] hoge;

    foreach (i; 0..N+1) {
        long co = N - 2 * i;

        auto l = co * A.front + mn * D;
        long r = co * A.front + mx * D;
        auto q = (l % (2 * D) + (2 * D)) % (2 * D);
        hoge[q] ~= tuple(l, r);

        mx = mx - i * 2;
        mn = mn - (N - i - 1) * 2;
    }

    long ans = 0;
    foreach (v; hoge.values) {
        v.sort();
        auto last = v.front[0] - 1;
        foreach (x; v) {
            auto a = x[0];
            auto b = x[1];
            a = max(a, last);
            if (a > b) {
                last = a;
                continue;
            }
            ans += (b - a) / (2 * D) + 1;
            last = b + 2 * D;
        }
    }

    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}
