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

#CCBCHBAHAI0000043. Loại các số âm, giữ nguyên thứ tự (Remove Negative Numbers While Preserving Order)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Loại các số âm, giữ nguyên thứ tự (Remove Negative Numbers While Preserving Order)

Loại các số âm, giữ nguyên thứ tự (Remove Negative Numbers While Preserving Order)

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given an integer array a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}.

Remove every negative element, i.e. every ai<0a_i<0. Zero and positive values must remain. The relative order of retained elements must not change.

Define

I={i∣0≤i<n, ai≥0}.I=\{i\mid 0\le i<n,\ a_i\ge0\}.

If I={i0<i1<⋯<im−1}I=\{i_0<i_1<\cdots<i_{m-1}\}, then

bj=aij,0≤j<m.b_j=a_{i_j},\qquad 0\le j<m.

Print mm and bb.

Input

The first line contains integer nn. The second line contains exactly nn integers a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}.

Output

Print the remaining size mm on the first line. If m>0m>0, print the resulting array on the second line.

Subtask

Subtask 1 (100 points): 1≤n≤2⋅1051\le n\le2\cdot10^5; ∣ai∣≤109|a_i|\le10^9.

Example

Input

5
-2 0 5 -1 3

Output

3
0 5 3

Explanation

The negative values −2-2 and −1-1 are removed; 0,5,30,5,3 remain in their original relative order.