Hi
Need some help about symetric matrix calculation. Need some generic formula to calculate in particular order.

-1 51 54 25 77
51 -1 44 70 96
54 44 -1 87 94
25 70 87 -1 88
77 96 94 88 -1

I want to add several items to make an array of sum in this order.
Example,
sum = 01 +12 + 23 + 34+ 45
(start with element row 0 column 1, last column number is index for next element)

some more example:
sum = 01 +13 + 34 + 45+ 52
sum = 01 +14 + 45 + 52+ 23
sum = 01 +15 + 52 + 23+ 34

sum = 02 +23 + 34 + 45+ 51
sum = 02 +24 + 45 + 51+ 13 and so on.

Each sum should take maximum number (maximum row or column, an item column is row for next item and each column is taken only one times)
as number of items in the matrix. If row and column is same we don't add it or if the cell value is -1.

How can I generelize these?

Br
Aktar