#include <bits/stdc++.h>
using namespace std;
#define mod ((long long)(1e9 + 7))

int main(void) {
  long long N, K;
  cin >> N >> K;
  long long ans = 0;
  for (int i = K; i <= N + 1; i++) {
    ans += (i * (N - i + 1)) + 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}