#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
    long long int n,k,i,j,min = 0,sum = 0;
    scanf("%lld%lld",&n,&k);
    for(i=0;i<k-1;i++){
        min += i;
    }
    for(i=k;i<=n+1;i++){
        min += i-1;
        sum += i*n - 2*min +1;
    }
    printf("%lld",sum%(1000000000 +7));
    return 0;
}