import strutils, sequtils, math proc readLine: auto = readLine stdin let N = readLine().parseInt var a, b = newSeqWith(N, 0) evenOdd = [1, 1] maxW, cnt = 0 proc width(i: int): int = a[i] + 4 * b[i] for i in 0 ..< N: (a[i], b[i]) = readLine().split.map parseInt evenOdd[a[i] mod 2] *= 0 if evenOdd.sum == 0: echo -1 quit() maxW = max(maxW, i.width) for i in 0 ..< N: cnt += (maxW - i.width) div 2 echo cnt