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