Pretty Indentation

Time limit1sMemory limit128 MB

Problem

A developer is cleaning up the indentation of source code at a small company. Indentation means placing tab characters before each line to represent its depth. The editor can select a consecutive group of lines and either add one tab to the front of every selected line or remove one tab from every selected line.

The code has N lines. For each line, you are given the current number of tabs and the target number of tabs. One edit consists of the following two steps.

  • Select one or more consecutive lines.
  • Add 1 tab before every selected line, or remove 1 tab from every selected line.

The whole operation counts as one edit regardless of how many lines are selected. However, removing a tab is not allowed if any selected line currently has no tab.

Find the minimum number of edits needed to make every line have its target number of tabs.

Input

The first line contains the number of lines N (1 <= N <= 1,000).

The second line contains the current tab counts of lines 1 through N in order. Each value is an integer between 0 and 80, inclusive.

The third line contains the target tab counts of lines 1 through N in order. Each value is also an integer between 0 and 80, inclusive.

Output

Print the minimum number of edits needed to make every line's indentation match the target state.