#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

int main(void){
  ll n, k, i;
  ll sum = 0;

  cin >> n >> k;

  ll right, left;
  right = (k-1) * k / 2;
  left = (n+n-k+1) * k / 2;

  for(i=k;i<=n+1;i++){
    sum += (left-right+1);
    sum %= MOD;

    right += i;
    right %= MOD;
    left += (n-i);
    left %= MOD;
  }

  if(sum<0) sum += MOD;

  cout << sum << endl;

  return 0;
}
