#include int main(void) { int i, N, a[1001], b[1001], num[1001], max, min; scanf("%d", &N); for(i = 1;i <= N;i++){ scanf("%d%d", &a[i], &b[i]); num[i] = a[i] + 4 * b[i]; //printf("%d ", num[i]); } for(i = 2;i <= N;i++){ if(a[1] % 2 != a[i] % 2){ printf("-1"); return 0; } } max = num[1]; min = num[1]; for(i = 2;i <= N;i++){ if(num[i] > max)max = num[i]; if(num[i] < min)min = num[i]; } //printf("%d %d\n", max, min); //printf("%d\n", ((max - min) / 2) ); printf("%d\n", (max - min) / 2); //else printf("%d\n", max - min); return 0; }