Stations#7301

Stations

0.1 seconds
64 megabytes
Easy

The management of the Very Large Railway (VLR) is introducing a new fare system. The VLR operates along a line with stations arranged sequentially. The plan is to divide these stations into contiguous zones, where each zone contains at least one station. The fare for traveling between station and station is determined by the formula 1 + |z_i − z_k|, where z_i and z_k are the zone numbers of stations and , respectively.

The number of passengers traveling daily from each station to every other station is known. Your task is to write a program that calculates the maximum possible daily revenue under this new fare system by optimally dividing the stations into zones.

Input

The input consists of lines. The first line contains two integers, and (1 \leq M \leq N \leq 1000). The second line contains a single number, representing the number of passengers traveling from station to station . The third line contains two numbers, indicating the number of passengers traveling from station to station and from station to station , respectively. This pattern continues, with the -th line containing N−1 numbers, where the -th number specifies the number of passengers traveling from station to station . The passenger numbers are given for both directions of travel between each pair of stations. All numbers are non-negative integers and do not exceed .

Output

The output should be a single integer, representing the maximum daily revenue that can be achieved with the optimal division of stations into zones.

Examples

Example 1

Loading
Loading