#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;

int N, K;

ll sum(ll l, ll r) {
    return (l+r) * (r-l+1) / 2;
}

int main(){
    cin >> N >> K;
    ll ans = 0;
    for (int i=K; i<=N+1; i++) {
        ll mn = sum(0, i-1);
        ll mx = sum(N+1-i, N);
        ans += mx - mn + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}