#include <iostream>
#include <cmath>
using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    const int MOD = 1000000007;
    long long add;
    long long sum = 0;

    for(long long i=k;i<=n+1;i++){
        long long minsum = i * (i - 1) / 2;
        long long maxsum = i * ((2 * n) - i + 1) / 2;
        add = maxsum - minsum + 1;
        sum = (sum + add) % MOD;
    }
    cout << sum << endl;
    return 0;
}