Minimum Product


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem type
Allowed languages
Python

Given an integer n, and n objects, the value of the i-th object is ai, you need to find the minimum value of \[ \sum_{i = 1}^{n} i * a_i \] However, you can swap the values of any two objects arbitrarily many times.

Input format:

An integer n, followed by n lines each containing an integer ai

Output format:

An integer, representing the minimum value.

Data range:

1 ≤ n ≤ 100000, 0 ≤ ai ≤ 100000

Input sample:

3
4
1
3

Output sample:

13

Comments

There are no comments at the moment.