#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 4050
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n+1;i++){
        ll a=(ll)i*(i-1)/2;
        ll b=(ll)i*(2*n+1-i)/2;
        ans+=(ll)(b-a+1);
        ans%=MOD;
    }
    OUT(ans);
    return 0;
}