#include <stdio.h>

int main(void)
{
    int N, K;
    scanf("%d %d", &N, &K);

    if (N + 1 == K) {
        printf("1\n");
        return 0;
    }
    if (N == K) {
        printf("%d\n", 1 + (N + 1));
        return 0;
    }

    long long result = 1 + (N + 1);
    long long i = 1;
    long long mod = 1000000007;
    long long n = (long long)N;
    while (N - i >= K) {
        long long max = ((i + 1 + n) * (n - i)) / 2;
        long long min = ((0 + n - i - 1) * (n - i)) / 2;
        result += (long long)((max - min) + 1);
        result = result % mod;
        i++;
    }
    printf("%lld\n", result);

    return 0;
}