#include <bits/stdc++.h>
using namespace std;
int main() {
  long int N, K;
  cin >> N >> K;
  long int total = 0;
  for (long int i = K; i <= N + 1; i++) {
    long int min = ((i - 1) * i / 2);
    long int max = ((N + N - i + 1) * i / 2);
    total += (max - min + 1) % 1000000007;
  }
  cout << total << endl;
}
