Problem:
Score : 400 points

Problem Statement

We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.

We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Constraints

1 \leq N \leq 2\times 10^5

1 \leq K \leq N+1

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible values of the sum, modulo (10^9+7).

Sample Input 1

3 2

Sample Output 1

10

The sum can take 10 values, as follows:

(10^{100})+(10^{100}+1)=2\times 10^{100}+1

(10^{100})+(10^{100}+2)=2\times 10^{100}+2

(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\times 10^{100}+3

(10^{100}+1)+(10^{100}+3)=2\times 10^{100}+4

(10^{100}+2)+(10^{100}+3)=2\times 10^{100}+5

(10^{100})+(10^{100}+1)+(10^{100}+2)=3\times 10^{100}+3

(10^{100})+(10^{100}+1)+(10^{100}+3)=3\times 10^{100}+4

(10^{100})+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+5

(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+6

(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\times 10^{100}+6

Sample Input 2

200000 200001

Sample Output 2

1

We must choose all of the integers, so the sum can take just 1 value.

Sample Input 3

141421 35623

Sample Output 3

220280457

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

#define int long long

using namespace std;

template<typename T>
void debug_out(T x) {
  cerr << x;
}

template<typename A>
void debug_out(vector<A> v) {
  cerr << '{';
  for (int i = 0; i < (int) v.size(); i++) {
    if (i) {
      cerr << ", ";
    }
    debug_out(v[i]);
  }
  cerr << '}';
}

template <typename A, typename B>
void debug_out(pair<A, B> p) {
  cerr << '(';
  debug_out(p.first);
  cerr << ", ";
  debug_out(p.second);
  cerr << ')';
}

template <typename A, typename B, typename C>
void debug_out(tuple<A, B, C> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ')';
}

template <typename A, typename B, typename C, typename D>
void debug_out(tuple<A, B, C, D> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ", ";
  debug_out(get<3>(p));
  cerr << ')';
}

template <size_t N>
void debug_out(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  cerr << res;
}

template <typename T>
void debug_with_endl(T v) {
  debug_out(v);
  cerr << endl;
}

template <typename Head, typename... Tail> 
void debug_with_endl(Head H, Tail... T) {
  debug_with_endl(H);
  debug_with_endl(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_with_endl(__VA_ARGS__)
#else
#define debug(...) 2003
#endif

const int md = (int) 1e9 + 7;

int normalized(int x) {
  while (x < 0) {
    x += md;
  }
  x %= md;
  return x;
}

int sum() {
  return 0;
}

template <typename Head, typename... Tail> 
int sum(Head H, Tail...T) {
  return normalized(normalized(H) + sum(T...));
}

int mul() {
  return 1;
}

template <typename Head, typename... Tail> 
int mul(Head H, Tail...T) {
  return normalized(normalized(H) * mul(T...));
}

int power(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int inv(int a) {
  return power(a, md - 2);
}

// pay attention to md's value first!
// use normalized form of modular integers for output!

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int k;
  cin >> k;
  auto Sum = [&](int x) {
    return mul(x, sum(x, 1), inv(2));
  };
  auto F = [&](int n, int k) {
    int x = Sum(k - 1);
    int y = (k == n + 1 ? Sum(n) : sum(Sum(n), mul(-1, Sum(n - k))));
    return sum(y, mul(-1, x), 1);
  };
  int ans = 0;
  for (int i = k; i <= n + 1; i++) {
    ans = sum(ans, F(n, i));
  }
  cout << normalized(ans) << '\n';
  return 0;
}