PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000021. Trồng cây (Planting Trees)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Trồng cây (Planting Trees)

Planting Trees

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn seedlings. Exactly one seedling can be planted per day; seedling ii needs gig_i days after planting to finish growing. The party is held on the first day after all trees have finished growing. Find the earliest possible party day.

Input

The first line contains nn. The second line contains gig_i. The first planting day is day 11.

Output

Print the earliest possible party day.

Constraints

  • 1≤n≤2⋅1051\le n\le 2\cdot10^5.
  • 1≤gi≤1091\le g_i\le 10^9 for 1≤i≤n1\le i\le n.

Subtasks

  • Subtask 1 (20 points): n≤8n\le 8.
  • Subtask 2 (30 points): n≤30n\le 30.
  • Subtask 3 (50 points): Full constraints.

Examples

Input

4
2 3 4 3

Output

7

Explanation

The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.