Turbo sort help

#include <stdio.h>

int main() {

int t, pos,i=0,j=0;
int arr[1000000];


scanf("%d",&t);
while(t--)
{
	scanf("%d",&pos);
	++arr[pos];
}

while(i<1000001){
  while(j<arr[i]){
   printf("%d\n",i);
  --arr[i];
  
  j++;
  }i++;}
return 0;

}

i am getting garbage values in my array…is it because i am using pointers?

//