import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); String s[]=bu.readLine().split(" "); long a=Long.parseLong(s[0]),b=Long.parseLong(s[1]); long times=maximum(a,b,0),M=(int)1e9+7; times-=minimum(a,b,0,times)-1; long l=0,r=(long)1e18,mid,ans=1; while(l<=r) { mid=(l+r)>>1; long v=maximum(a,b,mid); if(v==-1) v=0; else v-=minimum(a,b,mid,v)-1; if(v==times) { ans=mid+1; l=mid+1; } else r=mid-1; } //System.out.println(times+" "+ans); long fin=times%M*((ans*2-1)%M)%M; long ma=maximum(a,b,ans); if(ma==-1) times=0; else times=ma-minimum(a,b,ans,ma)+1; long A,N; //System.out.println(times); if(times%2==0) { A=2; N=times/2; } else { A=1; N=(times+1)/2; } //System.out.println(A+" "+N); long add=A*N%M; add+=N*N%M; add=add-N+M; add=add*2%M; //System.out.println(add); fin=(fin+add)%M; System.out.println(fin); } static long minimum(long a,long b,long m,long r) { if(m>a) return 0; long l=m-b,mid,ans=r; while(l<=r) { mid=(l+r)>>1; if(Math.abs(m-mid)<=b && Math.abs(m+mid)<=a) { ans=mid; r=mid-1; } else l=mid+1; } return ans; } static long maximum(long a,long b,long m) { if(a>1; if(Math.abs(m+mid)<=a) { ans=mid; l=mid+1; } else r=mid-1; } return ans; } }