// Slower C++ solution:
#include <algorithm>

#include <iostream>



using namespace std;



namespace mod {



template <class T, int M>

class MInt;



template <class T, int M>

MInt<T, M> Pow(const MInt<T, M> &base, T exp);



template <class T, int M>

MInt<T, M> Inv(const MInt<T, M> &n);



template <class T, int M>

class MInt {

  T n_;



 public:

  MInt() : n_(0) {}

  MInt(T n) : n_((n % M + M) % M) {}



  MInt &operator+=(const MInt &rhs) {

    n_ += rhs.n_;

    if (n_ >= M) {

      n_ -= M;

    }



    return *this;

  }



  MInt &operator-=(const MInt &rhs) {

    n_ += M - rhs.n_;

    if (n_ >= M) {

      n_ -= M;

    }



    return *this;

  }



  MInt &operator*=(const MInt &rhs) {

    n_ = n_ * rhs.n_ % M;

    return *this;

  }



  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }



  T Get() { return n_; }

};



template <class T, int M>

MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res -= rhs;

}



template <class T, int M>

MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res += rhs;

}



template <class T, int M>

MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res *= rhs;

}



template <class T, int M>

MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res /= rhs;

}



template <class T, int M>

MInt<T, M> Pow(const MInt<T, M> &base, T exp) {

  if (exp == 0) {

    return 1;

  }



  auto a = Pow(base, exp / 2);

  a *= a;

  if (exp % 2 == 1) {

    a *= base;

  }



  return a;

}



template <class T, int M>

MInt<T, M> Inv(const MInt<T, M> &n) {

  return Pow(n, static_cast<T>(M - 2));

}

}  // namespace mod



const int md = 1e9 + 7;

using MInt = mod::MInt<long long, md>;



int main(int argc, const char *argv[]) {

  int n, k;

  cin >> n >> k;



  MInt mn(n), mk(k);

  MInt ans = 0;

  for (int i = k; i <= n + 1; i++) {

    MInt mi(i);

    MInt min_n = (mi - MInt(1)) * mi / MInt(2);

    MInt max_n = (mn + (mn - mi + MInt(1))) * mi / MInt(2);

    ans += max_n - min_n + MInt(1);

  }



  cout << ans.Get() << '\n';



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.6052625152294x):
#include <algorithm>

#include <iostream>



using namespace std;



namespace mod {



template <class T, int M>

class MInt;



template <class T, int M>

MInt<T, M> Pow(const MInt<T, M> &base, T exp);



template <class T, int M>

MInt<T, M> Inv(const MInt<T, M> &n);



template <class T, int M>

class MInt {

  T n_;



 public:

  MInt() : n_(0) {}

  MInt(T n) : n_((n % M + M) % M) {}



  MInt &operator+=(const MInt &rhs) {

    n_ += rhs.n_;

    if (n_ >= M) {

      n_ -= M;

    }



    return *this;

  }



  MInt &operator-=(const MInt &rhs) {

    n_ += M - rhs.n_;

    if (n_ >= M) {

      n_ -= M;

    }



    return *this;

  }



  MInt &operator*=(const MInt &rhs) {

    n_ = n_ * rhs.n_ % M;

    return *this;

  }



  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }



  T Get() { return n_; }

};



template <class T, int M>

MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res -= rhs;

}



template <class T, int M>

MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res += rhs;

}



template <class T, int M>

MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res *= rhs;

}



template <class T, int M>

MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {

  MInt<T, M> res(lhs);

  return res /= rhs;

}



template <class T, int M>

MInt<T, M> Pow(const MInt<T, M> &base, T exp) {

  if (exp == 0) {

    return 1;

  }



  auto a = Pow(base, exp / 2);

  a *= a;

  if (exp % 2 == 1) {

    a *= base;

  }



  return a;

}



template <class T, int M>

MInt<T, M> Inv(const MInt<T, M> &n) {

  return Pow(n, static_cast<T>(M - 2));

}

}  // namespace mod



const int md = 1e9 + 7;

using MInt = mod::MInt<long long, md>;



int main(int argc, const char *argv[]) {

  int n, k;

  cin >> n >> k;



  MInt mn(n), mk(k), m1(1);

  MInt ans = 0;

  for (int i = k; i <= n + 1; i++) {

    MInt mi(i);

    ans += (mn - mi + m1) * mi + m1;

  }



  cout << ans.Get() << '\n';



  return 0;

}