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

ll Sum(ll num){
    ll sum1,sum2 = 0;
    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;
    Sum(num+1);
    return 0;
}

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