#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

/*** Loops ***/
#define ip(n) ll n; cin>>n;
#define ip2(n,k) ll n; cin>>n; ll k; cin>>k;
#define ff1(i,a,b) for(ll i = a; i < b; i++)
#define ff2(i,a,b) for(ll i = b-1; i >= a; i--)

/*** STLs ***/
#define vvll vector<vll>
#define pb push_back
#define mem(name, value) memset(name, value, sizeof(name))
#define MN3(n1,n2,n3) min(n1,min(n2,n3))
#define MN4(n1,n2,n3,n4) min(n1,min(n2,min(n3,n4)))
#define MX3(n1,n2,n3) max(n1,max(n2,n3))
#define MX4(n1,n2,n3,n4) max(n1,max(n2,max(n3,n4)))
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))

/***input loops***/
#define ipve(vc,n) vll vc(n); ff1(i,0,n){cin>>vc[i];}
#define ipvc(vc,n) vll vc; ff1(i,0,n){ip(x);vc.pb(x);}



/*** Typedef ***/
typedef long long ll;
//typedef long long lli;
typedef long long int lli;
typedef unsigned long long ull;
typedef    long double   ld;

// DEBUG
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

using namespace std;
int main(){

	ios::sync_with_stdio(false);
    cin.tie(0);//this reduced the time by 2ms
    
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif
    ll sum=0;
    ip(n);
    ip(k);
    ll v[n];
  //  ipvc(v,n); srt(v);
    ff1(i,0,n){
        cin>>v[i];
    }
    sort(v,v+n);
    ff1(i,0,3){sum+=v[i];}
    cout<<sum;
}
