n=gets.to_i xy=(0...n).to_a.map{|i|gets.split.map(&:to_i)} d=xy.map{|v|v[1]-v[0]}.uniq puts n>1 && d.size==1 && d[0] ? d[0] : -1