Recently I did some research on array templates, and it seems I got some interesting results. In Help:Template's description, we must set up arrays with a lot of templates. But now it is different. The following is a method to set up an n elements 1d array. (the italic words are some parameters to be specified.)
The usage is e.g. {{tmpltname|par[x]}}, and it gives val[x]. The exact size of the three templates can be calculated with the following formula:

So its space complexity is . And How about those arrays of higher dimensions? As we all know, the nd array in any programming language is based on 1d array. So it's easy to deal with nd arrays.
See also zh:template:babel-template/programming.