Do you need arrays to solve this problem at all? Looks like using simple math operations can give you what you need.