#include <bits/stdc++.h>
#define ll long long
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define mpi map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
ll n,k,ans;
int main() {
	cin>>n>>k;
	for(ll i=k;i<=n+1;i++){
		ans+=i*(n-i+1+n)/2-i*(i-1)/2+1;
	}
	cout<<ans%1000000007;
	return 0;
}
