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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007
using LL = long long;

LL sumNM(LL n, LL m) {
  return (n+m)*(m-n+1)/2;
}

int main()
{
  int N, K; cin >> N >> K;
  LL ans = 0;
  FOR(i, K, N+2) {
    ans = (ans + sumNM(N-i+1, N) - sumNM(0, i-1) + 1) % MOD;
  }
  cout << ans;
}