Si,j=Si1,j+Si,j1Si1,j1+ai,j S_{i,j}=S_{i-1,j}+S_{i,j-1}-S_{i-1,j-1}+a_{i,j}