Try to understand that starting case for j>i case is i=0 . You can run the loop till 2*n and do %n for making one solution work for both cases. Now all we have to worry about is a[i],b[i], and the sum so far.
These are the basic cases I thought of for i<n which will also work for the wrapping around case only with one catch. Try to figure the issue yourself.
See the next hint only if you've tried and failed.