#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
const long long MOD = 1e9 + 7;
int N, K;
long long ans;
int main() {
  int i, j;
  scanf("%d%d", &N, &K);
  long long a = 0, b = 0;
  for (i = 0; i <= N; i++) {
    a += i, b += N - i;
    if (K - 1 <= i) ans = ((ans + b - a + 1) % MOD + MOD) % MOD;
  }
  printf("%lld\n", ans);
}
