implementation of SuffixArray