#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  long long ans = 0;
  long long max = 0, min = 0;
  long long mod = pow(10, 9) + 7;
  for (int i = 0; i < K; ++i) {
    max += N - i;
    min += i;
  }
  for (int i = K; i <= N; ++i) {
    ans += (max - min + 1) % mod;
    ans %= mod;
    max += N - i;
    min += i;
  }
  ans += 1;
  ans %= mod;
  cout << ans;
}
