Points

No attempts yetTime limit3sMemory limit128 MB

Problem

John likes amusement parks. He goes every weekend and plays a different game. This weekend he found a hard one, a target shooting game.

The nn targets stand in a row along a straight line, numbered from 11 to nn from right to left. John picks the targets he wants to shoot, and every target he picks scores points. The score of target ii depends on how many of its neighbors, target i1i-1 and target i+1i+1, John picked as well.

  • aia_i points if he picked neither neighbor
  • bib_i points if he picked exactly one neighbor
  • cic_i points if he picked both neighbors

Target 11 and target nn have a single neighbor each, so they never have two picked neighbors. A target John does not pick scores nothing. Find the largest total score John can reach.

Input

The first line contains the number of targets nn. (n<1000000n < 1000000)

Each of the next nn lines contains the values aia_i, bib_i, and cic_i of target ii, separated by spaces, in order from i=1i = 1 to i=ni = n. (0ai,bi,ci10000 \le a_i, b_i, c_i \le 1000)

Output

Print the maximum number of points John can win on a single line.

Hint

The input is always well formed, and the file ends right after the last target. One input holds exactly one set of targets. Print the result to standard output from the beginning of a line.