Test cases are not getting passed (MAX VALUE IN AN ARRAY)

#include
using namespace std;

int max( int n, int brr[])
{

    int M=brr[0];

for(int i=1;i<=n;i++){
    if(brr[i]>brr[i-1])
    {
        M=brr[i];
    }
}
return M;

}

int main() {

  int N;
cin>>N;

  int arr[N];

for(int i=0;i<N;i++){
    cin>>arr[i];
}

    int ans;

ans=max(N,arr);
cout<<ans;
return 0;

}

hello @vanshit02

here pass it should be i<n
also u should compare brr[i] with M.
brr[i] > M