#K66577. Maximum Array Sum After Rotations

    ID: 32451 Type: Default 1000ms 256MiB

Maximum Array Sum After Rotations

Maximum Array Sum After Rotations

You are given an array of integers and an integer \(k\) which represents the maximum number of right rotations allowed. A right rotation moves the last element of the array to the first position. However, note that such rotations do not change the sum of the array.

Your task is to compute the maximum possible sum of the array after performing at most \(k\) right rotations. Since rotating the array rearranges the elements without altering their total, the answer is simply the sum of all the elements in the array.

Note: The input format for this problem is designed to read from standard input (stdin) and produce output to standard output (stdout).

inputFormat

The input is provided via standard input (stdin) and consists of two lines:

  • The first line contains two space-separated integers \(n\) and \(k\), where \(n\) is the number of elements in the array and \(k\) is the maximum number of right rotations allowed.
  • The second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

Output the maximum possible sum of the elements of the array. The result should be printed to standard output (stdout).

## sample
5 2
1 2 3 4 5
15