Maximum Sum on a Torus ( DP )