gets;p$<.map{|e|e=~/ /;eval"-~#$`/2*#$'"}.sum%(10^9+7)