#include<iostream>

long long mod = 1000000007;

long long left;
long long right;

long long sum(int a, int b);

int main(void) {
    int n, k;
    long long ret = 0;
    std::cin >> n >> k;
    if(n < k) {
        std::cout << 1 << std::endl;
        return 0;
    }
    left = sum(0, k - 1);
    right = sum(n - (k-1), n);

    ret += (right - left + 1);
    for(int i = k; i < n; ++i) {
        left += i;
        right += (n - i);

        ret += (right - left + 1);
        //std::cout << (right - left + 1) << std::endl;
        ret %= mod;
    }
    ret += 1;
    std::cout << ret  << std::endl;
}

long long sum(int a, int b) {
    long long ret = 0;
    for(int i = a; i <= b; ++i) {
        ret += i;
    }
    return ret;
}