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

int main(void)
{
  int N, K;

  scanf("%d %d", &N, &K);

  long long sum = 0;
  for (int i = K; i <= N + 1; i++)
  {
    sum += (i * ((long long)N - i + 1) + 1) % 1000000007;
    sum %= 1000000007;
  }
  printf("%lld", sum);

  return 0;
}
