#include <stdio.h>

int main(void){
    int n,k,i,j,ans=0,max=0,min=0;
    int up[200000];
    
    scanf("%d",&n);
    scanf("%d",&k);
    
    for(i=0;i<=n;i++){
        up[i]=i;
    }
    
    
    
    for(j=0;j<k;j++){
            min=min+up[j];
    }
    
    for(j=n;j>(n-k);j--){
            max=max+up[j];
    }
    
    ans=ans+(max-min+1)%(1000000007);
    
    
    for(i=k,j=0;i<=n;i++,j++){
        
        
        max=max+up[n-k-j];
        
        
        
        min=min+up[i];
        
        
        
        ans=ans+(max-min+1)%(1000000007);
        
        
    }
    
    printf("%d\n",ans);
    
    return 0;
}