import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

def main():
    N, K = map(int,input().split())
    P = list(map(int,input().split()))
    P.sort()
    print(sum(P[0:3]))

if __name__ == "__main__":
    main()