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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n+1);
  for(int i=0;i<=n;i++) p[i]=i;
  vector<long> q(n+2);
  q[0] = 0;
  for(int i=1;i<=n+1;i++) q[i] = q[i-1]+p[i-1];
  long ans = 0;
  long mod = 1000000007;
  for (int i=k;i<=n+1;i++){
    ans += (q[n+1]-q[n+1-i]-q[i]+1)%mod;
  }
  cout << ans%mod << endl;
}