This code is giving correct answer in vs code , but it’s not able to pass any test case can some one please help.
#include
using namespace std;
int main() {
long long int sum=0;
long long int n;
cin>>n;
long long int arr[n];
for(int i = 0; i < n; i++)
{
cin>>arr[i];
}
long long int operations;
long long int x;
cin>>operations;
while(operations--)
{
cin>>x;
for(int i = 0; i < n; i++)
{
if(x==0)
{
arr[i] = arr[i] + arr[i];
}
else{
arr[i] = arr[i] + x;
}
}
for(int i = 0; i < n; i++)
{
sum = sum + arr[i];
}
}
cout<<sum;
return 0;
}