HELPVOD: Need help

I am solving HELPVOD but my implementation seems to throw WA on codechef judge. Please help me in finding the error or the test cases it is failing. My implementation:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int n;
	int a[n];
	for(int i=0;i<n;i++)
    int sum,ans;
    sum = ans = 0;
    for(int i=0;i<n-1;i++)
        ans = a[i]*a[i+1];
        sum += ans;
        //<<sum<<" ";
	return 0;

yes bcoz ur using int for sum and in place of int u must use long is my link

1 Like

i have edited ur code and used long long and it has given write verdict.
pls do upvote

thank you…