#include #include using namespace std; long s[1010]; long t[1010]; int main(){ long n; cin >> n; long tmax = 0; long ans = -1; for(long i = 0; i < n; ++i){ long a, b; cin >> a >> b; s[i] = a; t[i] = b; long x = a + b * 4; tmax = std::max(tmax, x); } long sum = 0; for(long i = 0; i < n; ++i){ long x = tmax - (s[i] + t[i] * 4); sum += x; } if(sum % 2 == 0){ ans = sum / 2; } cout << ans << endl; }