Well, for that diagonal, you should note the following:
Sum up the digits that have their "x" and their "y" equal.
If you want to do the other diagonal too, think about this:
Sum up the digits that have their "x" and "y" sum up to the length of the square - 1.
( x + y = s )
( y = s - x )
Note what Kyon said. You just need to add which pairs have the same i and j. I'll give you a cool hint, you only need to use one loop and the items you'll add loop like this: x[i][i]