P14653 [CodeChef] AGECAL
提高-
题目描述

Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.

Chef's planet is called Javad. A year on Javad has $N$ months numbered $1$ through $N$. For each valid $i$, the $i$-th month has $a_{i}$ days numbered $1$ through $a_{i}$.

On Javad, years that are divisible by $4$ are leap years - the last month of each leap year is one day longer (it has $a_{N} + 1$ days).

You are given Chef's birth date and the current date. Find the age of Chef in days, i.e. the number of days between Chef's birth date and the current date inclusive.

------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $a_{1}, a_{2}, \ldots, a_{N}$.
The third line contains three space-separated positive integers $y_{b}$, $m_{b}$ and $d_{b}$ denoting the year, month and day of Chef's birth respectively.
The fourth line contains three space-separated positive integers $y_{c}$, $m_{c}$ and $d_{c}$ denoting the current year, month and day respectively.

------ Output ------
For each test case, print a single line containing one integer — Chef's age in days.

------ Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 10,000$
$1 ≤ a_{i} ≤ 10,000$ for each valid $i$
$1 ≤ y_{b}, y_{c} ≤ 100,000$
$1 ≤ m_{b}, m_{c} ≤ N$
$d_{b}$ will be less than or equal to the days of the $m_{b}$ month of the $y_{b}$ year.
$d_{c}$ will be less than or equal to the days of the $m_{c}$ month of the $y_{c}$ year.
the current date is equal to or greater than Chef's birth date

------ Subtasks ------
Subtask #1 (10 points):
$1 ≤ y_{b}, y_{c}, N ≤ 1,000$
$1 ≤ a_{i} ≤ 100$ for each valid $i$

Subtask #2 (90 points): original constraints

----- Sample Input 1 ------
4

5

1 2 3 4 5

2 1 1

3 5 1

2

3 3

1 1 1

2 2 2

2

1 1

3 1 1

3 2 1

5

1 4 3 4 6

3 5 6

10 1 1
----- Sample Output 1 ------
26

11

2

112

输入格式

见题面

输出格式

见题面

样例输入
4 5 1 2 3 4 5 2 1 1 3 5 1 2 3 3 1 1 1 2 2 2 2 1 1 3 1 1 3 2 1 5 1 4 3 4 6 3 5 6 10 1 1
样例输出
26 11 2 112