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

#PS0000173. Những người có thể vô địch (Accidental Victory)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Những người có thể vô địch (Accidental Victory)

Accidental Victory

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn players numbered 1 through nn, with initial token counts aia_i. Each match selects two players who still have tokens. The one with more tokens wins; a tie is resolved randomly. The winner takes every token of the loser, who is eliminated. After n−1n-1 matches one player remains. Every legal random choice has positive probability. Identify every player with a nonzero probability of becoming champion.

Input

Each Phuoc Hung OJ input file contains exactly one test case.

The first line contains integer nn.

The second line contains the nn integers a1,…,ana_1,\ldots,a_n in order.

Output

On the first line print the number of possible champions. On the second line print all their indices in increasing order, separated by spaces.

Subtasks

  • Subtask 1 (20 points): 1≤n≤5001\le n\le 500; 1≤ai≤1091\le a_i\le 10^9.
  • Subtask 2 (30 points): 1≤n≤2000001\le n\le 200000; 1≤ai≤1091\le a_i\le 10^9; a1=a2=⋯=ana_1=a_2=\cdots=a_n.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; 1≤ai≤1091\le a_i\le 10^9.

Example 1

Input

4
1 2 4 3

Output

3
2 3 4

Explanation

Player 1 cannot win a first match. Player 2 can defeat players 1, 4, 3 in that order, winning ties. Players 3 and 4 can also win by absorbing weaker players first.

Example 2

Input

5
1 1 1 1 1

Output

5
1 2 3 4 5

Explanation

Anyone can win a tie in the first match and then defeat the remaining players.