Problem

Source: INAMO 2023 P6 (OSN 2023)

Tags: combinatorics, counting, permutation, Indonesia, Indonesia MO



Determine the number of permutations $a_1, a_2, \dots, a_n$ of $1, 2, \dots, n$ such that for every positive integer $k$ with $1 \le k \le n$, there exists an integer $r$ with $0 \le r \le n - k$ which satisfies \[ 1 + 2 + \dots + k = a_{r+1} + a_{r+2} + \dots + a_{r+k}. \]