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

#TP0000035. Cuộc thi đua thuyền (Boats Competition)

HỌC THEO LỘ TRÌNH

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

2 lộ trình

Cuộc thi đua thuyền (Boats Competition)

Boats Competition

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn participants in a boat competition, and participant ii weighs wiw_i. Each team consists of exactly two distinct participants, and no participant may belong to more than one team. All formed teams must have the same total weight ss. You may choose ss to maximize the number of teams. Determine that maximum.

Input

  • The first line contains nn, the number of participants.
  • The second line contains exactly nn integers w1,w2,…,wnw_1,w_2,\ldots,w_n, their weights.

Output

Print one integer: the maximum possible number of disjoint teams sharing a common total weight ss.

Subtasks

  • Subtask 1 (20 points): 1≤n≤81\le n\le8; 1≤wi≤n1\le w_i\le n for all 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤251\le n\le25; 1≤wi≤n1\le w_i\le n for all 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤n≤501\le n\le50; 1≤wi≤n1\le w_i\le n for all 1≤i≤n1\le i\le n.

Examples

Input

5
1 2 3 4 5

Output

2

Explanation

Choose s=6s=6. Pair weights 11 and 55, then 22 and 44. The participant of weight 33 remains unpaired. Since five participants can form at most ⌊5/2⌋=2\lfloor5/2\rfloor=2 disjoint teams, two is optimal.