The output format is not correct
In SPOJ the output format should match with the required format.
It should be
cout<<a[i]<<endl;
as required, that is every output should be in new line.
and also
basic header file is also not included for the functionality of cin and cout i.e
include
I think that's the only corrections you need in this code.