#include<bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main(){
  long long n, k;
  cin >> n >> k;
  if(n <= k) cout << 1 << endl;
  else{
    vector<long long> sum(n + 1, 0);
    long long ans = 1;
    for(long long i = 0; i <= n; ++i){
      sum[i] = i * (i + 1) / 2;
    }
    for(int i = k; i <= n; ++i){
      ans += sum[n] - sum[n - i] - sum[i - 1] + 1;
      ans %= MOD;
    }
    cout << ans << endl;
  }
}