P26577 [AtCoder] Announcing the End of Heisei Era
普及+
题目描述

Problem Description

The year $ 2018 $ is coming to an end. Since the announcement of the new era starting on May 1, 2019, the year $ 2018 $ has become the year "Announcing the End of Heisei Era".

In the ancient PAKEN country, the first emperor ascended the throne on the Information Calendar year $ 1 $ month $ 1 $ day, and the $ i $-th emperor reigned for exactly $ a_i $ years. The abdication ceremony takes place on the last day of the year, December 31, and the coronation ceremony takes place on the first day of the year, January 1. Therefore, the era changes between December 31 and January 1 of the year when the emperor changes.

Since the current emperor is the $ N+1 $-th emperor, data on the reign periods of the $ 1 $-st to $ N $-th emperors is provided.

In PAKEN country, the last year of the $ i $-th ($1 \leq i \leq N$) emperor is called "Announcing the End of the 〇〇 Era".

How many times has the year "Announcing the End of the 〇〇 Era" occurred up to the Information Calendar year $ 2018 $? Count the year $ 2018 $ as well. Assume that the current year is after the Information Calendar year $ 2018 $.

Input Format

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

$ N $ $ a_1 $ $ a_2 $ $ a_3 $ : $ a_N $

Output Format

Output how many times the year "Announcing the End of the 〇〇 Era" has occurred up to the Information Calendar year $ 2018 $. Output the result in one line.

Sample Input and Output

Sample Input #1

3
700
700
700

Sample Output #1

2

Sample Input #2

2
2018
1

Sample Output #2

1

Sample Input #3

1
10000

Sample Output #3

0

Sample Input #4

20
188
186
234
175
172
157
244
108
81
297
331
323
185
162
216
143
141
225
200
177

Sample Output #4

10

Notes/Hints

Constraints

  • $ N $ is an integer between $ 1 $ and $ 8000 $ inclusive.
  • $ a_i $ is an integer between $ 1 $ and $ 10000 $ inclusive.

Sample Explanation 1

The $ 1 $-st emperor reigned from the Information Calendar year $ 1 $ to $ 700 $. Therefore, the Information Calendar year $ 700 $ is "Announcing the End of the 〇〇 Era". The $ 2 $-nd emperor reigned from the Information Calendar year $ 701 $ to $ 1400 $. Therefore, the Information Calendar year $ 1400 $ is "Announcing the End of the 〇〇 Era". The $ 3 $-rd emperor reigned from the Information Calendar year $ 1401 $ to $ 2100 $. Therefore, the Information Calendar year $ 2100 $ is "Announcing the End of the 〇〇 Era". The $ 4 $-th emperor is the current emperor, reigning from the Information Calendar year $ 2101 $. Therefore, up to now, the Information Calendar years $ 700, 1400, 2100 $ are "Announcing the End of the 〇〇 Era", but only $ 2 $ of them are on or before the year $ 2018 $. So, output $ 2 $.

Sample Explanation 2

The $ 1 $-st emperor reigned from the Information Calendar year $ 1 $ to $ 2018 $. Therefore, the Information Calendar year $ 2018 $ is "Announcing the End of the 〇〇 Era". The $ 2 $-nd emperor reigned from the Information Calendar year $ 2019 $ to $ 2019 $. Therefore, the Information Calendar year $ 2019 $ is "Announcing the End of the 〇〇 Era". The $ 3 $-rd emperor is the current emperor, reigning from the Information Calendar year $ 2020 $. Therefore, up to now, the Information Calendar years $ 2018, 2019 $ are "Announcing the End of the 〇〇 Era", but only $ 1 $ of them is on or before the year $ 2018 $. So, output $ 1 $.

Sample Explanation 3

Since the first emperor abdicates in the Information Calendar year $ 10000 $, there has been no "Announcing the End of the 〇〇 Era" year before the year $ 2018 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 700 700 700
样例输出
2