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

#GD0000158. Dãy có tổng xen kẽ bằng không (Ahahahahahahahaha)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Dãy có tổng xen kẽ bằng không (Ahahahahahahahaha)

Ahahahahahahahaha

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a binary sequence aa of even length nn. Remove at most n/2n/2 elements without reordering the remaining elements. Output a subsequence bb of length k≥n/2k\ge n/2 whose alternating sum b1−b2+b3−b4+⋯b_1-b_2+b_3-b_4+\cdots equals zero.

Input

The first line contains the even integer nn. The second contains nn values ai∈{0,1}a_i\in\{0,1\}.

Output

Print the length kk, then the kk retained elements in original relative order. Any valid subsequence is accepted.

Subtasks

  • Subtask 1 (20 points): 2≤n≤202\le n\le 20; nn chẵn; ai∈{0,1}a_i\in\{0,1\}.
  • Subtask 2 (30 points): 2≤n≤2002\le n\le 200; nn chẵn; ai∈{0,1}a_i\in\{0,1\}.
  • Subtask 3 (50 points): 2≤n≤10002\le n\le 1000; nn chẵn; ai∈{0,1}a_i\in\{0,1\}.

Examples

Input

6
1 0 1 0 0 0

Output

3
0 0 0

Explanation

The original array has four zeros. Keeping the zeros at positions 2,4,52,4,5 yields [0,0,0][0,0,0] after three deletions. Its alternating sum is 00, and its length is n/2=3n/2=3.