#B4234. Focus Training Plan

    ID: 11891 Type: Default 1000ms 256MiB

Focus Training Plan

Focus Training Plan

Little X sets a training plan for n days. On the ith day, he is scheduled to obtain \(a_i\) study points. However, his actual study points depend on his focus level \(S\) and a threshold \(m\) as described below:

  • Initially, \(S = 0\).
  • If on any day \(S \ge m\), he will earn double the study points, i.e. \(2 \times a_i\), and his focus level is updated to \(\lfloor S/2 \rfloor\).
  • If \(S < m\), he will earn only half of the study points (rounded down), i.e. \(\lfloor a_i/2 \rfloor\), and his focus level increases by \(a_i\).

Calculate the total study points he obtains after \(n\) days.

inputFormat

The first line of input contains two integers (n) and (m) separated by a space. The second line contains (n) space-separated integers (a_1, a_2, \ldots, a_n) representing the scheduled study points for each day.

outputFormat

Output a single integer representing the total study points obtained after (n) days.

sample

5 3
2 3 5 2 1
15