#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
void solve(){
    ll n, k;
    cin >> n >> k;
    ll p = 0, s = 0, ans = 0;
    for(ll i =1; i<=n+1; i++){
        s += i;
        p += n+2-i;
        s%=mod;
        p%=mod;
        if(i>=k){
            ans += p-s+mod+1;
            ans %mod;
        }
    }
    cout << ans%mod;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t =1, i = 1;
    //cin >> t;
    while(t--){
        solve();
        ++i;
    }
    return 0;
}
