#include <iostream>
#include <algorithm>
#include <cstdio>

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

using namespace std;

int main(void)
{
    int N;
    scanf("%d", &N);
    int K;
    scanf("%d", &K);
    int p[N] = {0};

    for (int i = 0; i < N; ++i)
    {
        scanf("%d", &p[i]);
    }
    sort(p, p + SIZE_OF_ARRAY(p));

    switch (N)
    {
    case 1:
        cout << p[0];
        break;
    case 2:
        cout << p[0] + p[1];
        break;
    default:
        cout << p[0] + p[1] + p[2];
        break;
    }
    cout << "\n";

    return 0;
}
