#include <stdio.h>

int main(void){
  int i;
  long int N,K,ans=0;
  scanf("%ld",&N);
  scanf("%ld",&K);
  for(i=N+1;i>=K;i--){
    ans += (N - i + 1) * i + 1;
    ans%=1000000007;
  }
  printf("%ld",ans);
}