You are right about the matrix, it has 2 variables, x and y, but for simplicity we suppose that we have 1 dimension matrix( a vector) with 1 row and N elements on it.

For example:

for the matrix [1 0 0 2]

S= |0-1|+ |0-0|+ |2-0|=3

f(n0)=1 f(n1)=0 f(n2)=0 and f(n3)=2