import sys input = sys.stdin.buffer.readline def main(): A,B = map(int,input().split()); MOD = pow(10,9) + 7 if A <= B: A += 1 ans = A*(A+1)*(2*A+1)//6 else: if A%2 == 1: a = 1 + (B//2)*2 a1 = 2*B + 1 - a else: a = 1 + (B//2)*2 a1 = 2*B + 1 - a a,a1 = a1,a ans = A*a + (A+1)*a1 print(ans%MOD) if __name__ == '__main__': main()