dp of size 3 with dp[0] = 0, dp[1] = -infinity, and dp[2] = -infinity.nums.dp.dp[(i + num) % 3] with the maximum of its current value and i + num, where i is an element from the copied state of dp.dp[0] as the maximum sum divisible by 3.