#include <bits/stdc++.h>
#define f(n) ((n + 1LL) * (n) / 2)
using namespace std;
const int mod = 1e9 + 7;

int main() {

    int n, k; 
	cin >> n >> k;
    int ans = 1;
    
    for (int i = k; i <= n; i++) 
        ans = (ans + f(n) - f(n - i) - f(i - 1) + 1) % mod;
    
    cout << ans << endl;
    return 0;
}