import qualified Data.ByteString.Char8 as B
import Data.Maybe
main=print.solve.map(fst.fromJust.B.readInteger).B.words=<<B.getLine
solve(a:b:_)
 |d<1=2*p
 |d<2=i*p
 |otherwise=0
 where
  (i,j)=if a>b then(a,b)else(b,a)
  d=i-j
  p=product[1..j]^2