#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

const long long MOD = 1e9 + 7;

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

	long long N, K;
	cin >> N >> K;

	long long result = 0;
	for (long long i = K; i <= N + 1; i++)
	{
		long long left = i * (i - 1) / 2;
		long long right = N * (N + 1) / 2 - (N - i) * (N - i + 1) / 2;
		long long count = right - left + 1;
		result = (result + count) % MOD;
	}

	cout << result % MOD;

	return 0;
}
