#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll mod = 998244353;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define S second
#define F first
#define M_PI 3.14159265358979323846

ll sqr(ll n) {
	return n*n;
}

ll gcd(ll a, ll b) {
	while(b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

bool prime(int n) {
	int i = 2;
	while (i*i <= n) {
		if (n % i == 0) return false;
		i++;
	}
	return true;
}
ll binpow(ll a, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 != 0) return binpow(a, n-1)*a; else {
		ll b = binpow(a, n/2);
		return b*b;
	}
}

const int MOD = 1e9 + 7;

ll calc(int n) {
	return (ll)(n) * (ll)(n+1) / (ll)(2);
}

ll getMax(int n, int i) {
	return calc(n) - calc(n-i);
}

ll getMin(int i) {
	return calc(i-1);
}

void solve() {
	int n, k;
	cin >> n >> k;
	ll dp[n+1];

	ll ans = 0;
	for (int i = k; i <= n+1; i++) {
		dp[i] = getMax(n, i) - getMin(i) + (ll)1;
		ans += dp[i];
		ans %= MOD;
	}

	cout << ans << endl;
}
 
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 5088