What is wrong in this code

#include
#include
using namespace std;
int main() {
long long int n;
cin>>n;
long long*arr=new long long[n];
long long int key;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
cin>>key;
auto f=find(arr,arr+n,key)-arr;
auto l=lower_bound(arr,arr+n,key)-arr;
if(f==n)
{
cout<<"-1";
}
else
{
cout<<l;
}
return 0;
}

u can’t use lower bound here
the array is not sorted
it will just return the first occurance
u have to give the last occurence