Sum of subarray elements#717

Sum of subarray elements

1 second
128 megabytes
Very easy (≈850)

Given a two-dimensional array of size n * m, your task is to find the sum of the elements within a specified subarray.

Input

The first line contains two integers, n and m (1 ≤ n, m ≤ 100), representing the number of rows and columns, respectively. This is followed by n lines, each containing m integers, which are the elements of the array.

The final line provides four integers: r_1, c_1, r_2, c_2 (r_1 ≤ r_2, c_1 ≤ c_2). These numbers specify the row and column indices of the top-left and bottom-right corners of the subarray. All array elements are integers with absolute values not exceeding 100. Note that the indexing starts from 1.

Output

Print the sum of the elements within the specified subarray.

Examples

Example 1

Loading
Loading