in a: =SUMIF(C3:C7,"<>0",A3:A7)
in c: =SUMIF(A3:A7,"<>0",C3:C7)

adjust the a3:a7/c3:c7 ranges as required