S, M = 0 ..

Do i = 1 to A._
 S, M = F (S, M, A.i)
;

S