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