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;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];

    long ans = 0;

    foreach (i; K..N+2) {
        long mn = 1L * i * (i - 1) / 2;
        long mx = 1L * N * (N + 1) / 2 - 1L * (N - i) * (N - i + 1) / 2;
        ans += (mx - mn + 1) % MOD;
        ans %= MOD;
    }

    ans.writeln;
}