#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = k; i <= n+1; i++){
        ans  += (ll)(n-i+1)*i+1;
        ans %= mod;
    }
    cout << ans <<  endl;
        
}