#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = 10 ^ 9 + 7;
ll modw(int N, int K);

int main() {
    int N, K; cin >> N >> K;
    cout << modw(N,K) << endl;
   

}
ll modw(int N, int K) {
    ll ans = 0, s = (N - K) * (N - K + 1) / 2, b = N * (N + 1) / 2 - s;
    while (K <= N) {
        ans += (b - s);
        b += (N - K);
        s -= (N - K);
        K++;
        ans %= mod;
    }
    return ans;
}