#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;
int main(){
    cin >> n >> k;

    ll res = 0;
    for(ll i=k; i<=n+1; i++){
        ll max = i*(2*n-i+1)/2;
        ll min = i*(i-1)/2;
        // out(max-min+1);
        res += (max - min+1)%mod;
    }
    out(res%mod);

 
}
