#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i< (n);i++)
#define rep1(i,n) for(int i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const static ll MOD = (1e+9)+7;

int main(){
    ll n,k;cin>>n>>k;
    ll ans = 0;
    ll before_min,before_max;
    for(ll i = 1;i<=n+1;i++){
        if(i == 1){
            if(i >= k){
                ans += n % MOD;
            }
            before_min = 1;
        }else{
            ll min_ = i*(i+1)/2;
            ll max_ = i*(2*n-i+1)/2;
            if(i >= k){
                ans += (max_-min_+1) % MOD;
                ans += max((ll)0,min_-before_min) % MOD;
            }
            before_min = min_;
        }
    }
    cout<<ans%MOD<<endl;
    return 0;
}