#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
const ll mod=1000000007;
int main() {
  ll n,k;cin>>n>>k;
  ll ans=0;
  for(int i=k;i<n+2;i++){
    ans+=i*(n-i+1)+1;
    ans%=mod;
  }
  cout<<ans%mod<<endl;
  return 0;
}