#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

ll n;
ll k;
ll fsum;
ll bsum;
ll ans;
int main() {
  cin >> n >> k;

  for(int i = 0; i < k; i++) fsum += i;
  for(int i = n; i > n - k; i--) bsum += i;
  ans += bsum - fsum + 1;
  for(int i = k; i <= n; i++) {
    fsum += i;
    bsum += n - i;
    ans += bsum - fsum + 1;
  }

  cout << ans % mod << endl;
}
  
 
