#include #include using namespace std; int main(void){ int n; long long a[n+1], b[n+1], sum_a=0,sum_b=0; cin >> n; for(int i=0; i> a[i] >> b[i]; if(abs( (sum_a + a[i]) - sum_b) <= abs((sum_b+b[i]) - sum_a) ){ sum_a += a[i]; }else{ sum_b += b[i]; } } cout << abs(sum_a - sum_b) << endl; return 0; }