#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

int main() {
  int N, K;
  cin >> N >> K;

  vector<long long> n(N + 1);
  for (int i = 0; i <= N; ++i) {
    n[i] = i;
  }
  for (int i = 0; i < N; ++i) {
    n[i + 1] += n[i];
  }

  long long ans = 0;
  for (int k = K; k <= N + 1; ++k) {
    ans = (ans + (N - k + 1 + N) * k / 2 - (k - 1) * k / 2 + 1) % MOD;
  }

  cout << ans << endl;
}