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

#define MOD 1000000007LL
const long long INF = 1LL << 60;

typedef long long ll;

ll addm(ll a, ll b){
    ll x = (a%MOD+b%MOD)%MOD;
    if (x < 0) x+=MOD;
    return x;
}

ll mulm(ll a, ll b){
    return(a%MOD*b%MOD)%MOD;
}

int main(){
    int N, K;
    ll ans=0;
    scanf("%d %d",&N,&K);
    for(ll i = K;i<N+2;i++){
        ans = addm(ans, addm( addm(mulm(N,i),-mulm(i,i)), addm(i,1LL)));
    }
    printf("%lld\n",ans);
    return 0;
}