#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;
int MOD = 1e9+7;
int main() {
  long long N, K;
    cin >> N >> K;
    long long res = 0;
    for (long long k = K; k <= N+1; ++k) {
        long long first = k * (k-1) / 2;
        long long final = (N*2-k+1) * k / 2;
        long long add = final - first + 1;
        res = (res + add) % MOD;
    }
    cout << res << endl;
}