n=gets.to_i a=n.times.map{gets.split.map(&:to_i).reduce(:-)}.uniq p a.size>1 ? -1 : a.first>=0 ? -1 : -a.first