#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#define NUM 1000000007
long long sum(long long begin,long long end){
        return (begin + end)* (end -begin+1)/2;
}
int main(){
    long long N,K;
    scanf("%lld %lld",&N,&K);
    long long ans = 0;
    for(long long i=K;i<=N+1;i++){
        ans += sum(N-(i-1),N) - sum(0,i-1) + 1;
        ans %= NUM;
    }
    printf("%lld",ans);
}
