#include <bits/stdc++.h>
using namespace std;
int main() {
  int mod = 1e9 + 7;
  long long int n, k;
  cin >> n >> k;
  n = n * (n + 1) / 2;
  n = n - k * (k - 1) / 2;
  n = n % (mod);
  cout << n << "\n";
}
