Fixed a definition and added support for if the index of A is assumed to be 1 instead of 0.