#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define pos position<int>
#define at_(p) at(p.x).at(p.y)

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

template <typename T>
class position {
public:
  position(T i=0, T j=0) {
    x = i;
    y = j;
  }
  position(pair<T, T> p) {
    x = p.first;
    y = p.second;
  }
  position(T a[]) {
    x = a[0];
    y = a[1];
  }
  T x;
  T y;
  position<T> operator + (position<T> p) { return position(this->x + p.x, this->y + p.y); }
  position<T> operator - (position<T> p) { return position(this->x - p.x, this->y - p.y); }
  position<T> operator + (pair<T, T> p) { return position(this->x + p.first, this->y + p.second); }
  position<T> operator - (pair<T, T> p) { return position(this->x - p.first, this->y - p.second); }
  position<T> operator + (T p[2]) { return position(this->x + p[0], this->y + p[1]); }
  position<T> operator - (T p[2]) { return position(this->x - p[0], this->y - p[1]); }
  void operator += (position<T> p) { this->x += p.x; this->y += p.y; }
  void operator -= (position<T> p) { this->x -= p.x; this->y -= p.y; }
  void operator += (pair<T, T> p) { this->x += p.first; this->y += p.second; }
  void operator -= (pair<T, T> p) { this->x -= p.first; this->y -= p.second; }
  void operator += (T p[2]) { this->x += p[0]; this->y += p[1]; }
  void operator -= (T p[2]) { this->x -= p[0]; this->y -= p[1]; }
  void swap() {
    std::swap(x, y);
  }
  pair<T, T> topair(){
    return make_pair(x, y);
  }
};

const long long P=1000000007;

int main(){
  //m ko: 1~m-(1-m+n)~n   m*(n-m)+1
  long long n,k;
  cin>>n>>k;
  
  long long cnt=0;
  for (long long m = k; m <= n+1; m++) {
    cnt+=m*(n-m+1)+1;
    cnt%=P;
   // cout<<cnt<<endl;
    
  }
  cout<<cnt;
}






/* きょむ〜 */


Measured memory_bytes: 3636