Reduce the calls to X.array[i] - and simplify