Jadie Wadie's Ladies


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python, Rust

Jaiden, also known as Jadie Wadie, loves to play poker. Jaiden's favourite hand in poker is when he has two queens, also known as the ladies in poker slang.

There are n cards total, arranged in a specific, fixed order that Jaiden knows in advance. Exactly m of these n cards are queens; the rest are irrelevant to Jaiden's goal. There are also k players, which includes Jaiden himself.

Normally, a dealer removes the card from the top of the deck to hand to a player. Jaiden however is good at sleight of hand, so in addition to a "normal deal" described earlier, he can also do a "bottom deal", where he removes a card from the bottom of the deck and deals it. Since this game is very casual, Jaiden can deal the cards out in whatever order he likes so long as each player recieves 2 cards in the end.

How many unique sets of cards allow Jaiden to deal himself two queens while dealing no queens to anyone else?

Input

The first line consists of 3 integers n, m and k, the number of cards in the deck, the number of queens in the deck, and the number of players. (2 \leq n \leq 10^{5}), (1 \leq 2k < n), (0 \leq m \leq n)

The next line consists of n integers 0 or 1, the order of the cards in the deck, read from the top of the deck to the bottom. 1's represent that the card is a queen, and 0's represent any other type of card.

Output

Output a single integer, the number unique sets of cards Jaiden can deal so that he can deal himself two queens and deal no one else in the game any queens. A set of cards is defined by the number of cards dealt from the top and the number of cards dealt from the bottom. Two sets are unique if either number differs.

Examples

Input 1
8 2 2
1 0 0 0 0 0 1 0
Output 1
2

The first way Jaiden can achieve this is by dealing 1 card from the top, and 3 cards from the bottom.

The second way Jaiden can achieve this is by dealing 2 cards from the top, and 2 cards from the bottom.

Input 2
8 2 2
0 0 0 1 1 0 0 0
Output 2
0

Comments

There are no comments at the moment.