This is a verified interview question from Smarsh. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Special Sum Calculation" covers key patterns like Arrays.
"Create a program that accepts a list, A, consisting of N distinct elements as input. This program will calculate and display a special sum, denoted as S, using the following procedure: 1. Arrange the elements in List A in ascending order. 2. Multiply each element in the sorted list by its respective position and add the largest element from the sorted list to each of these multiplications. 3. Sum up the results obtained from step 2 and output the final value as the special sum S. Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings while reading the input or while printing, as these contribute to the standard output."
Join thousands of developers practicing for Smarsh.