#!/usr/bin/env python
"""AtCoder Beginner Contest 171: B - Mix Juice
https://atcoder.jp/contests/abc17/tasks/abc171_b
"""


def main():
    N, K = list(map(int, input().split()))
    Ps = list(map(int, input().split()))

    ans = 0
    Ps.sort()
    for p in Ps[0:3]:
        ans += p
    print(ans)


if __name__ == '__main__':
    main()
