#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <tgmath.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007
int n, k;
ll nyan[222222] = {}, sum = 0;

main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i < 222222; i++)
    {
        nyan[i] = nyan[i - 1] + i;
    }
    for (int i = k; i <= n + 1; i++)
    {
        sum += nyan[n] - nyan[max(0, n - i)] - nyan[i - 1] + 1;
        sum %= mod;
        //printf("%lld\n", sum);
    }
    printf("%lld\n", sum);
}