Under construction

Still being built. Things may change

Number Game

Time limit2sMemory limit1024 MB

Summary
Given distinct integers, players place chips on a table while some common difference d of at least 2 must fit all table values; list Petya's winning first moves.
Level

Medium7 of 10

Topics
Game theory, Number theory, Bit manipulation
Solved
No attempts yet

Problem

An arithmetic progression with common difference dd is a sequence a1,a2,…,aka_1, a_2, \ldots, a_k in which the difference between any two consecutive terms is dd. For example, 2, 5, 8, 11 is an arithmetic progression with difference 3. Petya and Vasya play a game with a basket of nn chips. Each chip has a different integer written on it: a1,a2,…,ana_1, a_2, \ldots, a_n. The players take turns, and Petya moves first. On a turn, a player takes one chip from the basket and places it on the table. The player may choose any chip. Then the player must name an integer d≥2d \ge 2 such that every number on the chips now on the table is a term of some arithmetic progression with difference dd. The terms do not have to be consecutive. For example, if the table holds chips 2, 8, and 11, the player can name d=3d = 3. A player loses if they cannot move. That happens when the basket is empty, or when every chip left in the basket leads to a table with no valid dd. For example, if the basket holds 2, 3, 5, and 7, Petya can win by placing 3 first. Write a program that, given nn and the numbers a1,…,ana_1, \ldots, a_n, determines whether Petya can win no matter how Vasya plays, and finds every first move that leads to a win.

Input

The first line contains an integer nn (1≤n≤2001 \le n \le 200). The second line contains nn distinct integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1051 \le a_i \le 10^5). Adjacent numbers are separated by exactly one space.

Output

The first line contains kk, the number of different first moves that let Petya win. If Vasya can win no matter what Petya does, print only 0. Otherwise, the second line contains the kk winning numbers, separated by exactly one space.

Hint

If the basket holds only 2 and 4, Petya places either chip, Vasya places the other one, and Petya has no chip left to place, so Petya loses. The first example is explained in the statement above.

Examples2

  1. Example 1

    Input
    4
    2 3 5 7
    
    Expected output
    1
    3
    
  2. Example 2

    Input
    2
    2 4
    
    Expected output
    0