#K13481. Sum of Proper Divisors

    ID: 23922 Type: Default 1000ms 256MiB

Sum of Proper Divisors

Sum of Proper Divisors

Given a list of positive integers, replace each integer with the sum of its proper divisors. A proper divisor of a number \(x\) (with \(x > 1\)) is any positive divisor other than \(x\) itself. For \(x = 1\), define the sum as 0. Formally, for any integer \(x > 1\), compute:

\( S(x) = \sum_{d\mid x,\; d < x} d \)

For example, the proper divisors of 12 are 1, 2, 3, 4, and 6; hence \(S(12)=16\). Your task is to take a list of integers and output a new list where each integer is replaced by the sum of its proper divisors.

inputFormat

The input consists of two lines:

  • The first line contains an integer \(n\), the number of elements in the list.
  • The second line contains \(n\) space-separated positive integers.

outputFormat

Output a single line containing \(n\) space-separated integers, where each integer is replaced by the sum of its proper divisors.

## sample
6
6 28 12 10 15 21
6 28 16 8 9 11