#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    int n,k;
    cin >> n >> k;
    vector<ll> v1(n+1);
    ll ans=0;
    v1[0]=0;
    REP(i,n+1){
        if(i==0)continue;
        v1[i]=v1[i-1]+i;
    }
    vector<ll> v2(n+1);
    v2[0]=n;
    IREP(i,n+1){
        if(i==n)continue;
        v2[n-i]=v2[n-i-1]+i;
    }
    for(int i=k;i<=n+1;i++){
        ans += v2[i-1]-v1[i-1]+1;
        ans%=MOD;
    }
    cout << ans << endl;
}