n=gets.to_i x,y=(0...n).to_a.map{|i|gets.split.map(&:to_i)}.transpose.map{|v|v.inject(:+)} u=-1 u = (y-x)%n==0 ? (y-x)/n : -1 u = -1 if n==1 puts u