One test case giving wrong answer

#include
using namespace std;
void last(int a[],int n,int l,int key){
if(n<0){
cout<<"-1";
}
if(a[l]==key){
cout<<l;;
}
else{
last(a,n,l-1,key);
}
}
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int k;
cin>>k;
last(arr,n,n-1,k);
return 0;
}
this code is not passing 1 test case

@professor check for this
7
86 -16 77 65 45 77 28
43
your o/p garbage but correct ans -1
dont forget to hit like and mark resolved if cleared :smiley:

@professor
6
1 2 3 4 3 1
5
your o/p -8
corrected code