#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
const MOD: usize = 1_000_000_000 + 7;
fn main() {
    input!(N: usize, K: usize);
    let mut v = vec![0; N + 1];
    for i in 0..N + 1 {
        v[i] = i;
    }

    v.sort();
    let mut sum = vec![0; N + 2];
    for i in 0..N + 1 {
        sum[i + 1] = sum[i] + v[i];
    }

    let mut ans = 0;
    // sum[i+1] = a_0 + a_1 + + a_i
    // a_0 + + a_m-1 = sum[m]
    // a_N+1-m + + a_N = sum[N+1] - sum[N+1-m]
    for m in K..=N + 1 {
        let max = sum[N + 1] - sum[N + 1 - m];
        let min = sum[m];
        ans += max - min + 1;
        ans %= MOD;
    }
    println!("{}", ans);
}

#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
struct Mod {
    val: usize,
}

// 和を定義
impl std::ops::Add for Mod {
    type Output = Mod;
    // O(1)
    fn add(self, other: Mod) -> Mod {
        Mod {
            val: (self.val + other.val) % Mod::MOD,
        }
    }
}

// 差を定義
impl std::ops::Sub for Mod {
    type Output = Mod;

    // O(1)
    fn sub(self, other: Mod) -> Mod {
        Mod {
            val: (self.val + MOD - other.val) % Mod::MOD,
        }
    }
}

// 積を定義
impl std::ops::Mul for Mod {
    type Output = Mod;

    // O(1)
    fn mul(self, other: Mod) -> Mod {
        Mod {
            val: (self.val * other.val) % Mod::MOD,
        }
    }
}

// 加法単位元
impl std::ops::Neg for Mod {
    type Output = Mod;

    // O(1)
    fn neg(self) -> Mod {
        Mod {
            val: Mod::MOD - self.val,
        }
    }
}

// 逆元を定義
// フェルマーの小定理により実装
impl std::ops::Div for Mod {
    type Output = Mod;

    //O(logN)
    fn div(self, other: Mod) -> Mod {
        self * other.inv()
    }
}

impl Mod {
    const MOD: usize = 1_000_000_000 + 7;
    // コンストラクター
    fn new(n: usize) -> Mod {
        Mod { val: n % Mod::MOD }
    }

    // 加法単位元
    fn new_zero() -> Mod {
        Mod { val: 0 }
    }

    // 乗法単位元
    fn new_one() -> Mod {
        Mod { val: 1 }
    }

    // 加法逆元
    // 上記にて定義

    // 乗法逆元
    fn inv(self) -> Mod {
        if self.val == 0 {
            panic!("zero divide");
        }
        self.pow(Mod::MOD - 2)
    }

    // 累乗を定義
    // O(logN)
    fn pow(self, n: usize) -> Mod {
        let mut res = 1;
        let mut a = self.unwrap();
        let mut n = n;

        while n > 0 {
            if n % 2 == 0 {
                a = a * a;
                n /= 2;
            } else {
                res = res * a;
                a = a * a;
                n /= 2;
            }
            res %= Mod::MOD;
            a %= Mod::MOD;
        }
        Mod::new(res)
    }

    // 最大公約数
    // O(logN)
    fn gcd(self, other: Mod) -> usize {
        let mut x = self.val;
        let mut y = other.val;
        while y != 0 {
            let t = y;
            y = x % y;
            x = t;
        }
        x
    }

    // 階乗
    // O(N)
    fn fact(self) -> Mod {
        let mut res = 1;
        for i in 1..self.val + 1 {
            res *= i;
            res %= Mod::MOD;
        }

        Mod::new(res)
    }

    // 順列
    fn perm(self, other: Mod) -> Mod {
        let mut res = Mod::new_one();
        for x in (self.val - other.val + 1)..self.val + 1 {
            res = res * Mod::new(x);
        }

        res
    }

    // 組み合わせ O(N)
    fn conb(self, other: Mod) -> Mod {
        if self < other {
            return Mod::new_zero();
        }
        self.fact() / (other.fact() * (self - other).fact())
    }
    fn unwrap(self) -> usize {
        self.val % Mod::MOD
    }
}


Measured memory_bytes: 4980