#include <bits/stdc++.h>
using namespace std;

using vi = vector<int>;
using ll = long long;
using ld = long double;

#define rep(i,a,b) for(auto i = (a); i < (b); ++i)
#define trav(a,x) for(auto& a: x)
#define all(a) begin(a),end(a)
#define sz(a) (int)size(a)
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MOD = 1000000007;
const int inv2 = 500000004;
auto add(auto a, auto b){return ((ll) a + b) % MOD;}
auto sub(auto a, auto b){return ((ll) a - b + MOD) % MOD;}
auto mult(auto a, auto b){return (ll) a * b % MOD;}
auto sum(auto a, auto b) { // inclusive
  auto gap = (b - a + 1);
  auto res = add(mult(gap, a), mult(mult(gap, gap - 1), inv2));
  return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    ++n; // so we can work on range [1...n]
    auto res = 0LL;
    rep(taken, k, n + 1) {
      auto lo = sum(1, 1 + taken - 1);
      auto hi = sum(n - taken + 1, n);
      auto delta = add(sub(hi, lo), 1);
      //cout << lo << " " << hi << endl;
      //cout << delta << '\n';
      res = add(res, delta);
    }
    cout << res << '\n';
        
    
}
