Construct the Lexicographically Largest Valid Sequence

Given an integer n, build an array of length 2n - 1 that satisfies all of these rules:

  • The value 1 appears exactly once.
  • Every value from 2 through n appears exactly twice.
  • For every value x from 2 through n, the two occurrences of x are exactly x positions apart, so if one occurrence sits at index i, the other sits at index i + x.

Return the lexicographically largest valid array.

Examples
Input: 1
Output: [1]
Hints

Construct the Lexicographically Largest Valid Sequence

Given an integer n, build an array of length `2n - 1` that satisfies all of these rules: