#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  ll N; cin >> N;
  ll K; cin >> K;
  ll MOD = 1000000007;
  ll s=0;
  for(int i=K;i<N+2;i++){
    s+=(i*(N-i+1))%MOD + 1;
  }
  cout << s%MOD << endl;
  return 0;
}