#include using namespace std; using ll = long long; #define rep(i, n) for (int i=0; i<(int)(n); ++(i)) #define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i)) #define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i)) #define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i)) #define all(x) (x).begin(), (x).end() const ll mod = (ll)(1e9) + 7; struct mint { ll x; mint(ll x=0) : x((x%mod+mod)%mod) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;} mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; istream& operator>>(istream& is, mint& a) { return is >> a.x; } ostream& operator<<(ostream& os, const mint& a) { return os << a.x; } int main() { ll a, b; cin >> a >> b; ll hval = (a + b) / 2, lval = hval - b; ll val = b + 1, sub = lval - (-hval) + 1; mint res = val; res *= sub; if (val > 1) { if ((a+b)%2 == 1) { ll lval2 = lval + 1, val2 = val - 1, sub2 = lval2 - (-hval) + 1; mint res2 = val2; res2 *= sub2; res += res2; } else { ll hval2 = hval - 1, val2 = val - 1, sub2 = lval - (-hval2) + 1; mint res2 = val2; res2 *= sub2; res += res2; } } cout << res << endl; return 0; }