#C8759. Shift and Sum

    ID: 52776 Type: Default 1000ms 256MiB

Shift and Sum

Shift and Sum

You are given a list of integers and an integer k. Your task is to perform a left bitwise shift on each integer in the list by k positions and then compute the sum of all the shifted values. In other words, for each integer x in the list, you must compute

\(x \ll k = x \times 2^k\)

and output the sum of all such computed values.

Input Format: The first line contains an integer n representing the number of integers. The second line contains n space-separated integers. The third line contains the non-negative integer k indicating the number of left bitwise shifts to perform.

Output Format: Output a single integer which is the sum of all the shifted integers.

inputFormat

The input is read from standard input (stdin) with the following format:

  • The first line contains a single integer n, the number of elements in the list.
  • The second line contains n space-separated integers.
  • The third line contains a non-negative integer k, which specifies the number of positions to shift.

outputFormat

Output a single integer to standard output (stdout) representing the sum of all the integers after performing the left bitwise shift operation by k positions on each.

## sample
4
1 2 3 4
2
40