#include <cstdio>
using namespace std;
const int mod = 1000000007;
int N,K,ans;
int main() {
    scanf("%d%d",&N,&K);
    for (int i = K;i <= N + 1;i++) {
        ans += (((1LL * (N - i + 1 + N) * i) >> 1) - ((1LL * (i - 1) * i) >> 1) + 1) % mod;
        ans %= mod;
    }
    printf("%d\n",ans);
}
