#include <stdio.h>
#define dr 1000000007

int main(){
  long n,k,d[200005],i,m=0,a;
  scanf("%ld",&n);
  scanf("%ld",&k);
  d[1]=n;
  a=1;
  for(i=1;i<=n;i++){
    d[i+1]=(d[i]+n-(i<<1))%dr;
  }
  for(i=k;i<=n+1;i++){
    m+=d[i]+1;
    m%=dr;
  }
  printf("%ld",(m+dr)%dr);
  return(0);
}