Permutation Addition

AtCoder
IDarc159_c
Time2000ms
Memory256MB
Difficulty
You are given a sequence of positive integers: $A=(a_1,\ldots,a_N)$. Determine whether it is possible to make all elements of $A$ equal by repeating the following operation between $0$ and $10^4$ times, inclusive. If it is possible, show one way to do so. * Choose a permutation $(p_1,\ldots,p_N)$ of $(1,\ldots,N)$, and replace $A$ with $(a_1+p_1,\ldots,a_N+p_N)$. ## Constraints * $2 \leq N \leq 50$ * $1 \leq a_i \leq 50$ * All values in the input are integers. ## Input The input is given from Standard Input in the following format: $N$ $a_1$ $\ldots$ $a_N$ [samples]
Samples
Input #1
2
15 9
Output #1
Yes
8
1 2
1 2
1 2
1 2
2 1
1 2
1 2
1 2

This sequence of $8$ operations makes $A = (24,24)$, where all elements are equal.
Input #2
5
1 2 3 10 10
Output #2
No
Input #3
4
1 1 1 1
Output #3
Yes
0

All elements of $A$ are equal from the beginning.
API Response (JSON)
{
  "problem": {
    "name": "Permutation Addition",
    "description": {
      "content": "You are given a sequence of positive integers: $A=(a_1,\\ldots,a_N)$. Determine whether it is possible to make all elements of $A$ equal by repeating the following operation between $0$ and $10^4$ time",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc159_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a sequence of positive integers: $A=(a_1,\\ldots,a_N)$.\nDetermine whether it is possible to make all elements of $A$ equal by repeating the following operation between $0$ and $10^4$ time...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments