#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, i, K, total;
  scanf("%d%d", &N, &K);
  total = 0;
  for (i = K; i <= N + 1; ++i) {
    total += (N + 1 - i) * 1LL * i % 1000000007 + 1;
    total %= 1000000007;
  }
  printf("%d", total);
  return 0;
}
