#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k, p = 1e9 + 7;
    cin >> n >> k;
    long r = 0;
    for(; k < n + 2; k++)
        (r += k * long(n + 1 - k) + 1) %= p;
    cout << r << endl;
    return 0;
}
