#K79442. Total Blooming Flowers in a Circular Garden

    ID: 35309 Type: Default 1000ms 256MiB

Total Blooming Flowers in a Circular Garden

Total Blooming Flowers in a Circular Garden

You are given a circular garden divided into n sections, where each section has a certain number of blooming flowers. The garden is arranged in a circular fashion, so that after the n-th section, it wraps back to the 1st section. Starting from a given section with index s (1-indexed), you are required to traverse the garden in order and calculate the total number of blooming flowers.

The order of traversal is given by the sequence:

$s, s+1, \ldots, n, 1, 2, \ldots, s-1$

Since you will visit each section exactly once, the task simplifies to computing the sum of all the flower counts. However, the twist in the problem is to simulate the circular traversal starting from section s.

Note: Even though the result is equivalent to the sum of all elements, ensure your implementation follows the circular order as specified.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer n representing the number of sections in the garden.
  • The second line contains n space-separated integers representing the number of blooming flowers in each section.
  • The third line contains an integer s (1-indexed) representing the starting section.

outputFormat

Output a single integer which is the total number of blooming flowers. The output should be written to stdout.

## sample
5
3 0 4 2 5
3
14