#include <iostream>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;



void solve() {
    ll n, k; scanf("%I64d %I64d", &n, &k);
    ll sum = 0;
    for (ll i = k; i <= n+1; i++) {
        ll minimum = ((i)*(i-1))/2;
        ll maximum = ((2*n-i+1)*(i))/2;
        sum += (maximum-minimum+1) % mod;
        sum %= mod;
    }
    printf("%I64d", sum);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}