Feedback for FIRSTANDLAST problem

Problem Link: FIRSTANDLAST Problem - CodeChef

Feedback

int n;
cin>>n;
int a[n];

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    int sum=a[0]+a[n-1];
    
     for(int i=0;i<n-1;i++)
    {
        int temp=a[i]+a[i+1];
        
        sum=max(sum,temp);
    }
    
    std::cout << sum << std::endl;

Why this Solution is not Passing all the test cases
Even if it is Showing the Answers Correctly