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

using E = System.Linq.Enumerable;
using System.Collections;

public class Program
{
    const long Mod = (long)1e9 + 7;

    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, k) = (nk[0], nk[1]);

        var count = 
            from sum in Aggregation.How((Modular<long> t, long y) => from x in t select x + y)
            select Modular<long>.Empty(Mod) into sum
            from x in
                from x in E.Range(k, n + 1 - k + 1)
                select (long)x into x
                select x * (n - x + 1) + 1
            select x;

        Console.WriteLine(count.Value);
    }

}

static class Aggregation
{
    public static Aggregation<T, R> How<T, R>(Func<R, T, R> accumulator) => new Aggregation<T, R>(accumulator);
}

class Aggregation<TSource, TAccumulate>
{
    Config config;
    public bool SeedWithFirst { get; set; }

    internal struct Config
    {
        public TAccumulate Seed;
        public readonly Func<TAccumulate, TSource, TAccumulate> Accumulator;

        public Config(TAccumulate x, Func<TAccumulate, TSource, TAccumulate> f) => (Seed, Accumulator) = (x, f);

        public override bool Equals(object obj)
        {
            return obj is Config other &&
                EqualityComparer<TAccumulate>.Default.Equals(Seed, other.Seed) &&
                EqualityComparer<Func<TAccumulate, TSource, TAccumulate>>.Default.Equals(Accumulator, other.Accumulator);
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(Seed, Accumulator);
        }

        private TAccumulate Aggregate(IEnumerable<TSource> collection) => collection.Aggregate(this.Seed, this.Accumulator);

        public static TAccumulate Perform(Aggregation<TSource, TAccumulate>.Config behavior, IEnumerable<TSource> collection)
            => behavior.Aggregate(collection);

        public static S Perform<S>(Aggregation<S, S>.Config behavior, IEnumerable<S> collection, bool seedWithFirst)
            => behavior.Aggregate(behavior.Treat(collection, seedWithFirst));

        private IEnumerable<TAccumulate> Treat(IEnumerable<TAccumulate> collection, bool seedWithFirst)
        {
            using var e = collection.GetEnumerator();
            var s = this.Seed;
            if (seedWithFirst && e.MoveNext())
            {
                this.Seed = e.Current;
            }
            while (e.MoveNext())
            {
                yield return e.Current;
            }
            this.Seed = s;
        }

        public void Deconstruct(out TAccumulate x, out Func<TAccumulate, TSource, TAccumulate> f) => (x, f) = (Seed, Accumulator);

        public static implicit operator (TAccumulate X, Func<TAccumulate, TSource, TAccumulate> F)(Config value) => (value.Seed, value.Accumulator);
        public static implicit operator Config((TAccumulate X, Func<TAccumulate, TSource, TAccumulate> F) value) => new Config(value.X, value.F);
    }

    public Aggregation(TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator) => (config, SeedWithFirst) = ((seed, accumulator), false);
    public Aggregation(Func<TAccumulate, TSource, TAccumulate> accumulator) => (config, SeedWithFirst) = ((default, accumulator), true);

    public static void Usage()
    {
        var z =
            from _ in Aggregation.How((Modular<long> t, long y) => from x in t select x + y)
            select Modular<long>.Empty(13) into a
            from i in E.Range(11, 5).Select(x => (long)x)
            select i;
        Console.Error.WriteLine(z.Value);
    }

    public Aggregation<TSource, TAccumulate> Select(Func<Config, TAccumulate> selector)
    {
        this.config.Seed = selector(this.config);
        this.SeedWithFirst = false;
        return this;
    }

    public static TAccumulate SelectManyTrans<TCollection>(
        Aggregation<TSource, TAccumulate> ag,
        Func<Config, IEnumerable<TCollection>> collectionSelector,
        Func<Config, TCollection, TSource> resultSelector)
    {
        if (ag.SeedWithFirst)
        {
            throw new InvalidOperationException();
        }
        var xs = collectionSelector(ag.config).Select(x => resultSelector(ag.config, x));
        return Aggregation<TSource, TAccumulate>.Config.Perform(ag.config, xs);
    }

    public static TAccumulate SelectManyCis<TCollection>(
        Aggregation<TAccumulate, TAccumulate> ag,
        Func<Aggregation<TAccumulate, TAccumulate>.Config, IEnumerable<TCollection>> collectionSelector,
        Func<Aggregation<TAccumulate, TAccumulate>.Config, TCollection, TAccumulate> resultSelector)
    {
        var xs = collectionSelector(ag.config).Select(x => resultSelector(ag.config, x));
        return Aggregation<TCollection, TCollection>.Config.Perform(ag.config, xs, ag.SeedWithFirst);
    }
}

static class AggregationExtension
{
    public static TAccumulate SelectMany<TSource, TCollection, TAccumulate>(
        this Aggregation<TSource, TAccumulate> aggregation,
        Func<Aggregation<TSource, TAccumulate>.Config, IEnumerable<TCollection>> collectionSelector,
        Func<Aggregation<TSource, TAccumulate>.Config, TCollection, TSource> resultSelector) 
        => Aggregation<TSource, TAccumulate>.SelectManyTrans(aggregation, collectionSelector, resultSelector);

    public static TAccumulate SelectMany<TCollection, TAccumulate>(this Aggregation<TAccumulate, TAccumulate> aggregation,
        Func<Aggregation<TAccumulate, TAccumulate>.Config, IEnumerable<TCollection>> collectionSelector,
        Func<Aggregation<TAccumulate, TAccumulate>.Config, TCollection, TAccumulate> resultSelector) 
        => Aggregation<TAccumulate, TAccumulate>.SelectManyCis(aggregation, collectionSelector, resultSelector);
}
    
readonly struct Modular<TSource>
{
    public readonly long Mod;
    public readonly TSource Value;

    public Modular(TSource x, long m) : this() => (this.Value, this.Mod) = (x, m);
    public static Modular<TSource> Empty(long m) => new Modular<TSource>(default, m);
    public Modular<long> Return(long x) => new Modular<long>((x % this.Mod + this.Mod) % this.Mod, this.Mod);
    public Modular<TResult> Return<TResult>(TResult x) => new Modular<TResult>(x, this.Mod);

    public Modular<long> Select(Func<TSource, long> selector) => this.Return(selector(this.Value));
    public Modular<TResult> Select<TResult>(Func<TSource, TResult> selector) => this.Return(selector(this.Value));
    public Modular<TResult> SelectMany<TCollection, TResult>(Func<TSource, TCollection> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
        => this.Select(x => resultSelector(x, collectionSelector(x)));
    public Modular<TResult> SelectMany<TCollection, TResult>(Func<TSource, Modular<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
        => this.SelectMany(x => collectionSelector(x).Value, resultSelector);
}


Measured memory_bytes: 41160