Maybe could just initialize "a" with [tempArray[0]] and then iterate from i=1 instead of i=0.