// #pragma GCC optimize(“O2”)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include<bitset>
using namespace std;
#define pi 3.14159265358979323846264338327950254
 #define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);//************************************


using namespace std;

typedef long long LL;
typedef long long ll;

const int N = 300010, mod = 1e9 + 7;


int fact[N], infact[N];


int qmi(int a, int k, int p)
{
    int res = 1;
    while (k)
    {
        if (k & 1) res = (LL)res * a % p;
        a = (LL)a * a % p;
        k >>= 1;
    }
    return res;
}

ll pre[N];
int main()
{
    //STDIN
    

    int a, b;
    scanf("%d%d", &a, &b);
    for (int i = 1; i <= a+1; i++)
    {
        pre[i] += pre[i-1] + i-1;
    }
    ll sum = 0;
    for (int i = b; i <= a + 1; i++)
    {
        sum = (pre[a+1]-pre[a-i+1]-pre[i] +1 + sum)% mod;
    }
    cout << sum << endl;

    return 0;
}
