Wrong Answer Please Help

#include<bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
int a[n], i = 0;
while(nā€“) cin >> a[i++];
int mx = 0;
for(int i = 0; i < n; i++) mx = max(mx, a[i]);
cout << mx;
}

Please use FOR loop for input instead of while loop.