Array max value

The below code passes for all testcases except test case 3.Although running it locally produces the correct output.

#include <iostream>

using namespace std;

int main() {
    long long int numOfElements = 0;
    long long int a[10] = {0};
    long long int max = a[0];
    cin >> numOfElements;
    a[numOfElements] = {0};
    for (long long int i = 0; i < numOfElements; i++) {
        cin >> a[i];
    }
    for (long long int i :a) {
        if (i > max) max = i;
    }
    cout << max;
}

Please help

Hey @ghanesh.balaji1995
Your code will not work when all elements of array are negative.

eg. when input is
3
-4 -6 -2

Yes i have made a change by intializing the max value to be INT_MIN