#include <iostream>
using namespace std;
int main(void){
    int64_t N, K;
    cin >> N >> K;
    
    int64_t sum = 0;
    
    for (int i = 0; i < N - K + 2; i++){
        sum += ((N - K + 1 - i) + N) * (K + i) / 2 - (0 + (K + i - 1)) * (K + i) / 2 + 1;
    }
            if (sum > 1000000007)
            sum %= 1000000007;
    cout << sum << endl;
}
