#include <bits/stdc++.h>
using namespace std;

#define ll long long
ll mod = 1000000007;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    n=n+1;
    if(n==k) cout << 1 << "\n";
    else {
        ll sum=0;
        ll count=n;
        for(int i=0; i<=n; i++){
            if(i>=k-1){
                if(i==0) sum+=(count%mod);
                else sum+= ((count%mod)*(i%mod))%mod;
            }
            count--;
        }
        cout << sum << "\n";
    }

    return 0;
}