import std.stdio, std.conv, std.string, std.range, std.math, std.algorithm; void main() { auto N = readln.strip.to!int; int[] X, Y; foreach (_; 0 .. N) { auto input = readln.split.to!(int[]); X ~= input[0]; Y ~= input[1]; } auto ans = zip(X, Y).map!(a => a[1]-a[0]).uniq; (ans.count > 1 || ans.front < 1 ? -1 : ans.front).writeln; }