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