Read a positive natural number n followed by n integers forming a sequence v[1], v[2], ..., v[n]. A contiguous subarray v[i], v[i+1], ..., v[j] has alternating signs if, traversed from left to right, the elements alternate between positive and negative: positive, negative, positive, negative, ... or the reverse.
Determine the length of the longest such subarray and print its elements. If the value 0 appears in the sequence, it breaks any alternating-sign run (a zero element is neither positive nor negative).
If there are several subarrays of maximum length, choose the first one.