#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  ll n, k; cin >> n >> k;
  ll ans = 0;
  for(ll i = k; i <= n+1; i++){
    ll a = n*(n+1)/2;
    ll b = (n-i)*(n-i+1)/2;
    ll c = (i-1)*i/2;
    ans += (a-b) - c + 1;
    ans %= MOD;
  }
  cout << ans << endl;
  system("pause");
}
