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

int main(){
  
  long long N; long long K;
  cin >> N >> K;
  long long J;
  J = N+1-K;
  cout << ((J*(J+1)/2)*(N+1)-J*(J+1)*(2*J+1)/6+J+1)%1000000007 << endl;
  
}