In the C++ code below, I got an **out of bounds error on the last line**.

```
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++)
   cin>>a[i];
while(n--)
   {a[n]-a[n-1];}

```

There shouldn't be an issue since in the while loop, n will first get decremented and then it will start executing the code in the loop.

I have run it on multiple IDEs and it ran fine, but gave me an out of bounds error when I tried to submit the solution on codeforces.