#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-21 20:42:23 +0900
# LastModified: 2020-06-21 21:09:42 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    n,k = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()
    print(sum(p[:3]))


if __name__ == "__main__":
    main()
