#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

ll cnt(ll n,ll x) {
  ll res=0;
  rep(i,0,n) {
    res+=i*(-max(x-i,(ll)0));
    res+=(n-i)*(max(x-i,(ll)0));
  }
  res+=x;
  return res;
}

int main(void) {
  ll MOD=pow(10,9)+7;
  int n,k;cin>>n>>k;
  pr((cnt(n,n+1)-cnt(n,k-1))%MOD);
  return 0;
}
