Your problem is at the som variable. Please you pay attention to som calculation in the the nested loop.
your som started with value of 8, in the first iteration of i, where i = 3, you have som=som-i which is 5. then you get into j loop, which has som-- in each iteration, where you end up with som = 3 at the end of all iteration.
in the second iteration of i, where i = 2, you have som = som - i which 3 - 2 = 1. After first iteration of j, with the som--, you end up with som = 0. After second iteration of j, with the som--, you end up with som = -1. Which is outside of range of your array.
You need to rethink your algorithm again so som will be inside valid value range.
Hope that helps. [ October 11, 2005: Message edited by: Wirianto Djunaidi ]