#include #include using namespace std; const int size=1e5+10; int n; int d[size]; int x,y; int dist; int ans; bool dfs(int i,int sum,int c) { //cout << i << endl; if(c>2)return false; if(sum>dist)return false; if(i>n)return false; if(sum==dist) { ans=min(ans,sum); return true; } if(dfs(i+1,sum,c))return true; if(dfs(i+1,sum+d[i],c+1))return true; return false; } int main() { cin >> n; for(int i=0;i> d[i]; cin >> x >> y; dist=abs(x)+abs(y); //1 ans=1; for(int i=0;i()); if(dfs(0,0,0))cout << ans << endl; else cout << -1 << endl; return 0; }