Q:

I need to decrease first n elements of an array by 1

I would like to decrease the first n-elements in an array by 1. I tried this but its not working
int n = 3;

for(int i = 0 ; i <array.length;i++) {

        while(i<=n){

         array[i]-=1;
         }          

}

A:

let's say n=3
int n =3;

for(i = n-1; i >= 0; i--)
{
    array[i]-=1;
}

Alternatively as @locus2k points out we can also iterate through the array starting at the 0th index as so
int n = 3;
for(i = 0; i < n; i++)
{
    array[i]-=1;
}

