Vacation

No attempts yetTime limit5sMemory limit64 MB

Problem

Jianjia is planning a vacation in Taiwan. nn cities lie along one highway, numbered 00 through n1n-1. City ii is adjacent only to i1i-1 and i+1i+1, except the endpoints, which have one neighbor.

City ii has aia_i attractions. Jianjia has dd vacation days and chooses a starting city before the trip begins. Each day, exactly one of these actions is allowed.

  • Move to an adjacent city.
  • Visit every attraction in the current city that has not been visited yet.

Attractions in a city are never counted twice. Find the maximum number of distinct attractions Jianjia can visit.

Input

  • Line 1: nn, starting city startstart, and vacation length dd
  • Line 2: a0a_0 through an1a_{n-1}, the attraction counts in order

Output

Print the maximum number of attractions that can be visited.