Life,the universe and Everything

Whats problem with my code??

#include
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}

for(int i=0;i<n;i++)
{
if(a[i]!=42)
cout<<a[i]<<endl;
else
break;
}
}

There is no need of defining the variable n. Please read the input/output format again