#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  ll n,k,ans = 0,mod = 1e9+7;
  cin >> n >> k;
  for(int i = k;i <= n+1;i++){
    ans += i*(n-i+1)+1;
    ans %= mod;
  }
  cout << ans << endl;
}