#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  
  //累積和
  vector<ll> sum(N+2);
  for( ll i = 0; i <= N; i++ ) sum.at(i+1) = sum.at(i)+i;
  
  ll ans = 0;
  for( ll i = K; i <= N+1; i++ ){
    ll MIN = sum.at(i);
    ll MAX = sum.at(N+1) - sum.at(N+1-i);
    ans += (MAX-MIN)+1;
    ans %= MOD;
  }
  cout << ans << endl;
}