#!/usr/bin/evn perl use strict; use warnings; my $n = <>; my $i = 0; my @array; while($i < $n) { my($x, $y) = split / /, <>; $array[$i] = $y - $x; $i++; } $i = 1; while($i < $n) { if(($array[$i - 1] != $array[$i])or($array[$i] <= 0)) { print "-1\n"; exit; } $i++; } print "$array[0]\n"; exit;