#include <iostream>
#include <vector>
#define MOD 1e9+7
using namespace std;

int main() {
    int N, K, i;
    uint64_t ans = 0;
    cin >> N >> K;
    for(i=K; i<=N+1; i++) {
        ans += (i*(N-i+1)+1);
        ans %= (uint64_t)MOD;
    }
    cout << ans;
}