Getting wrong ans on correct code

please check my submission. I am confused. why my code is showing wrong ans.

#include<bits/stdc++.h>
using namespace std;

int main() {
int n;
int gas[n], cost[n];

for(int i=0; i<n; i++){
	cin>>gas[i];
}
for(int i=0; i<n; i++){
	cin>>cost[i];
}
int net = 0, curr = 0,start = 0;
for(int i=0; i<n; i++){
	net += (gas[i] - cost[i]);
	curr += (gas[i] - cost[i]);
	if(curr < 0){
		start = i+1;
		curr = 0;
	} 
}
if(net < 0) cout<<"-1";
else cout<<start;

return 0;

}

Hello @sinhaa.aankit
dry run for this test case:
4
8 8 2 10
7 7 5 9
output: 3
please confirm.
Happy Learning!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.