#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,m,k,sum=0,a=0,b=0;
  long long mod = 1000000007;
  cin >> n >> k;
  for (long long i=k;i<=n;i++){
    a = k*(k+1)/2;
    b = n*(n+1)/2 - (n-k)*(n-k+1)/2;
    sum += b - a + 1;
    sum %= mod;
  }
  cout << sum << endl;
}