get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).
 
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

main :-
  get_number(N),
  get_number(K),
  Ans is (N*(N+1)*(N+2)/6-K*(K-1)*(3*N-2*K+4)/6+(N-K+2)) mod 1000000007,
  writeln(Ans).