#P2367. 语文成绩

语文成绩

Description

The Chinese teacher always writes scores wrong, so when she corrects them, she gets exhausted. She keeps adding points again and again to certain students, and she also needs to keep track of the minimum score. Can you help her?

Input Format

The first line has two integers nn, pp, representing the number of students and the number of additions.

The second line has nn numbers, a1ana_1 \sim a_n, representing each student's initial score.

The next pp lines each have three numbers, xx, yy, zz, representing adding zz points to each student from the xx-th to the yy-th, inclusive.

Output Format

Output only one line, representing the class minimum score after the changes.

3 2
1 1 1
1 2 1
2 3 1
2

Hint

For 40%40\% of the testdata, n103n \le 10^3.

For 60%60\% of the testdata, n104n \le 10^4.

For 80%80\% of the testdata, n105n \le 10^5.

For 100%100\% of the testdata, n5×106n \le 5\times 10^6, pnp \le n, initial scores 100\le 100, z100z \le 100.

Translated by ChatGPT 5