Can someone tell why this code is giving wrong outout?

int Solution::solve(vector &v) {
long long sum=-1,a=0,b=0,c=0;

for(long long i=v.size()-1;i>=0;i--){
    if(v[i]!=a&&v[i]!=b&&v[i]!=c){
         if(v[i]>a){
             a=v[i];
             b=0;
             c=0;
         }else if(v[i]>b){
             b=v[i];
             c=0;
         }else if(v[i]>c){
             c=v[i];
         }
    //   cout<<a<<" "<<b<<" "<<c<<" "<<sum<<'\n';
         if(a>b&&b>c&&a!=0&&b!=0&&c!=0){
               sum=max(a+b+c,sum);
             
         }
    }
}

return sum;
// long long ans=*max_element(v1.begin(),v1.end());
// if(v1.size()==0)return -1;
//  else return ans;

}

I think that you are trying to get 3  numbers {largest ,second largest ,  third largest }

but consider that [2, 1 ,7 ,6]
your output is: 1+7+6 = 14
     this case  A[i]<A[j]!< A[k]

but actually answer is 2+1+7 =10
this case i<j<k and  A[i]<A[j]<A[k]

Click here to start solving coding interview questions