#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 1000000007
typedef long long ll;
int N, K;
ll rem = 0;
ll sum1, sum2 = 0;

ll Sum(ll num)
{
    ll sum1, sum2;
    if (num == N + 2)
        return 0;
    sum1 = num * (num - 1) / 2;
    sum2 = num * (2 * (N - num + 1) + (num - 1)) / 2;
    rem += sum2 - sum1 + 1;
    rem %= BUFSIZE;
    return Sum(num + 1);
}

int main(void)
{
    scanf("%d", &N);
    scanf("%d", &K);
    Sum(K);
    printf("%lld", rem % BUFSIZE);
    return 0;
}
