## Algorithm

Problem Name: 2 AD-HOC - beecrowd | 2548

# 3D Virtual Museum

By Flávio Zavan, UFPR Brazil

Timelimit: 1

Vasya and Petya are visiting the 3D virtual museum of history of the capital. To have fun, they decided to do a little prank. The prank consists on damaging M models among the N exposed ones. Vasya illegally downloads the model’s file, Petya opens it in a 3D editor and replaces historical details by Fibonacci numbers, and then he puts it back into the museum.

Every time a model is damaged, its value is nullified. Since the duo is really evil, they decided to make the museum have the highest loss possible. Given N, M and the value of each exposed models, write a program to calculate the highest loss they can make.

## Input

The input contains several test cases. The first line of each test case contains two integers, N (0 ≤ N ≤ 103) and M (0 ≤ MN). The second line contains N integers (between 0 and 1000), the value each model has (in nlogonian dollars), in non-decreasing order.

The input ends with end-of-file (EOF).

## Output

For each test case, print a single line containing the highest possible loss they can make.

 Input Sample Output Sample 4 2 0 0 2 3 7 1 33 44 55 789 790 791 987 5 987

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````

#include <stdio.h>
#include <stdlib.h>

#define true 1
#define false 0
#define MAX 1100

int main (void)
{

short i;
unsigned soma;
unsigned short n, m;
unsigned short vetor[MAX];

while (scanf("%hu %hu", &n, &m) != EOF)
{

for (i = 0; i  <  n; ++i)
scanf("%hu", &vetor[i]);

soma = 0;
for (i = 1; i  < = m; ++i)
soma += vetor[n - i];

printf("%u\n", soma);

}

}
``````
Copy The Code &

Input

cmd
4 2
0 0 2 3
7 1
33 44 55 789 790 791 987

Output

cmd
5
987