#include <stdio.h>

int main(){
  int N, K;
  scanf("%d %d", &N, &K);
  long i;
  long sum = 0;
  long a = 1000000007;
  for (i = (long)K; i <= (long)N + 1L; i++) {
    //unsigned long min, max;
    //min = (i * (2 * 0 + i - 1)) / 2;
    //max = (i * (2 * N - i + 1)) / 2;
    long b = (((2L * i * (N - i + 1L)) / 2L) + 1L) % a;
    sum = (sum + b) % a;
    //printf("%lu\n", b);
  }
  printf("%ld\n", sum);
  return 0;
}