P23656 [AtCoder] Attendance Management
普及-
题目描述

Problem Description

Punch-kun's company uses an IC card system for attendance management. When he touches his IC card to the computer, it records the time of arrival and departure.

In this system, breaks can also be managed by touching the IC card. For example,

  • Time 300
  • Time 500
  • Time 600
  • Time 800

(in minutes) would be interpreted as:

  • Arrival
  • Break start
  • Break end
  • Departure

and the total working time excluding breaks would be calculated as 400 minutes. Multiple breaks can be taken.

Given Punch-kun's IC card data for a single day, calculate the total working time from the first arrival to the last departure. Note that it is impossible for the number of timestamps to be odd, in which case output "error" (without double quotes).

Input Format

The input is given from the standard input in the following format:

$ N $ $ a_1 $ $ a_2 $ ... $ a_N $

  • The first line contains the number of timestamps $N\ (1\ ≦\ N\ ≦\ 100)$.
  • The second line contains $ N $ timestamps $a_i\ (0\ ≦\ a_i\ ≦\ 1440)$ in order, separated by spaces.
  • It is guaranteed that $a_i\ <\ a_j$ when $i\ <\ j$.

Output Format

Output the total working time in one line. Ensure a newline at the end of the output.

Sample Input and Output

Sample Input #1

4
300 500 600 800

Sample Output #1

400

Sample Input #2

2
0 1440

Sample Output #2

1440

Sample Input #3

6
540 600 720 780 960 1020

Sample Output #3

180

Sample Input #4

3
1 2 3

Sample Output #4

error

Notes/Hints

Sample Explanation 1

This is the example from the problem statement.

Sample Explanation 2

There might be no breaks. You shouldn't work in such a black company.

Sample Explanation 3

Multiple breaks can be taken. Punch-kun is slacking off quite a bit.

Sample Explanation 4

The number of timestamps cannot be odd.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 300 500 600 800
样例输出
400