#K94102. Prime Indices

    ID: 38567 Type: Default 1000ms 256MiB

Prime Indices

Prime Indices

Given a list of integers, return a new list containing only the elements at indices that are prime numbers.

An index i is considered if and only if it is a prime number. Note that indices start from 0, and by definition, numbers less than 2 are not prime. A prime number \( p \) is defined as a natural number greater than 1 that has no positive divisors other than 1 and \( p \), i.e., \[ p > 1 \quad \text{and} \quad \forall d\, (d|p \Rightarrow d \in \{1, p\}). \]

Your task is to read an array of integers from standard input and output the elements located at prime indices, preserving their original order. If no such indices exist, output an empty line.

inputFormat

The input is read from standard input and consists of two lines:

  1. The first line contains a single integer \( n \) representing the number of elements in the array.
  2. The second line contains \( n \) space-separated integers.

outputFormat

Output to standard output a single line with the elements located at prime indices separated by a single space. If no such elements exist, output an empty line.

## sample
6
10 15 20 25 30 35
20 25 35