#include <bits/stdc++.h>
using namespace std;
#define optimize() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
typedef long long ll;
typedef double dl;
#define endl '\n'
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define nl cout << endl
ll ans = 0;
ll solve(int n, int m, int i)
{
if(i > n) return 0;
int temp; cin >> temp;
solve(n, m, i+1);
if(i >= m) ans += temp;
return ans;
}
int main()
{
optimize();
int n, m;
cin >> n >> m;
ll res = solve(n, m, 1);
cout << res << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIG9wdGltaXplKCkgICAgICAgICAgICAgICAgXAogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsgXAogICAgY2luLnRpZSgwKTsgICAgICAgICAgICAgICAgICAgXAogICAgY291dC50aWUoMCk7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBkb3VibGUgZGw7CgojZGVmaW5lIGVuZGwgJ1xuJwojZGVmaW5lIHllcyBjb3V0IDw8ICJZRVMiIDw8IGVuZGwKI2RlZmluZSBubyBjb3V0IDw8ICJOTyIgPDwgZW5kbAojZGVmaW5lIG5sIGNvdXQgPDwgZW5kbAoKbGwgYW5zID0gMDsKbGwgc29sdmUoaW50IG4sIGludCBtLCBpbnQgaSkKewogICAgaWYoaSA+IG4pIHJldHVybiAwOwogICAgaW50IHRlbXA7IGNpbiA+PiB0ZW1wOwogICAgc29sdmUobiwgbSwgaSsxKTsKICAgIGlmKGkgPj0gbSkgYW5zICs9IHRlbXA7CiAgICByZXR1cm4gYW5zOwp9CmludCBtYWluKCkKewogICAgb3B0aW1pemUoKTsKICAgIAogICAgaW50IG4sIG07CiAgICBjaW4gPj4gbiA+PiBtOwogICAgbGwgcmVzID0gc29sdmUobiwgbSwgMSk7CiAgICBjb3V0IDw8IHJlcyA8PCBlbmRsOwoKICAgIHJldHVybiAwOwp9