#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, k;
string s, t;
vector<int> v, pref;

int32_t main(){_
   
   cin >> n >> k;
   ++n;

   for (int i = 0; i < n; ++i)
   {
      v.push_back(i);
      if (pref.empty()){
         pref.push_back(i);
      }
      else{
         pref.push_back(pref.back()+i);
      }
   }

   int ans = 0;
   for (int i = k-1; i < n; ++i)
   {
      //starting k and ending k
      int st = pref[i];
      int sz = (int)(pref.size());
      int end = pref.back() - ((sz-1-i-1 < 0) ? 0 : pref[sz-1-i-1]);
      ans += end - st + 1;
      ans %= mod; 
   }

   cout<<ans;

   return 0;
}