#C13614. Every N-th Element

    ID: 43172 Type: Default 1000ms 256MiB

Every N-th Element

Every N-th Element

Given a list of integers and an integer \(n\), return a new list that contains every \(n\)-th element of the original list. The list is considered 1-indexed, meaning the first element is at position 1.

If \(n \le 0\) or if there is no valid \(n\)-th element in the list, the output should be an empty list.

inputFormat

The input is read from standard input (stdin) and consists of three parts:

  1. An integer \(m\) on the first line representing the number of elements in the list.
  2. If \(m > 0\), a second line containing \(m\) space-separated integers.
  3. A third line containing an integer \(n\), the interval at which elements should be selected.

outputFormat

Print the elements that are at every \(n\)-th position from the list, separated by a space, to standard output (stdout). If there are no such elements, output an empty line.

## sample
10
1 2 3 4 5 6 7 8 9 10
3
3 6 9