#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
  ll n,k;
  cin >> n >> k;
  ll s[n+1]={};
  r(i,n)s[i+1]=s[i]+i+1;
  ll ans=0;
  for(int i=k;i<=n+1;i++){
    if(i==n+1)ans+=1;
    else{
      ans+=(s[n]-s[n-i])-s[i-1]+1;
    }
  }
  cout<<ans%mod<<endl;
}