using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    const long Mod = (long)1e9 + 7;
    
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var (n, k) = (nk[0], nk[1]);

        var count = new Modular(0, Mod);
        for (; k <= n + 1; ++k)
        {
            count += k * (n - k + 1) + 1;
        }
    
        Console.WriteLine(count.Value);
    }
    
    readonly struct Modular
    {
        public readonly long Mod;
        public readonly long Value;

        public Modular(long x, long m) : this() => (this.Value, this.Mod) = ((x + m) % m, m);

        public static Modular operator +(Modular a, long x) => new Modular(a.Value + x, a.Mod);
        public static Modular operator -(Modular a, long x) => new Modular(a.Value - x + a.Mod, a.Mod);
        public static Modular operator *(Modular a, long x) => new Modular(a.Value * x, a.Mod);
        public static Modular operator /(Modular a, long x) => new Modular(a.Value / x, a.Mod);
    }
}
