/**
    F11 COMPETITION
    Problema: strung
    Runda: 3
    Echipa: Quicksilver
**/

#include <algorithm>
#include <fstream>
using namespace std;

#define INPUT "strung.in"
#define OUTPUT "strung.out"
#define MAX_PIECES_NUMBER 1001
#define MAX_LATHES_NUMBER 101

int nLathes, nPieces, sol;
int procTime[MAX_PIECES_NUMBER], heap[MAX_LATHES_NUMBER];

/** READ **/
void read() {
    ifstream fin(INPUT);
    fin >> nLathes;
    fin >> nPieces;
    for (int i = 0; i < nPieces; ++i)
        fin >> procTime[i];
    fin.close();
}

/** SOLVE **/
void doDownHeap(int node) {
    int sonNode;
    while (node < nLathes) {
        if ((node << 1) <= nLathes) {
            sonNode = node << 1;
            if (sonNode + 1 <= nLathes && heap[sonNode + 1] < heap[sonNode])
                ++sonNode;
        }
        else
            return;
        if (heap[sonNode] < heap[node]) {
            swap(heap[sonNode], heap[node]);
            node = sonNode;
        }
        else
            return;
    }
}

void updateHeap(int node, int value) {
    heap[node] += value;
    doDownHeap(node);
}

void solve() {
    for (int i = 0; i < nPieces; ++i) {
        updateHeap(1, procTime[i]);
    }
    for (int i = 1; i <= nLathes; ++i)
        sol = max(sol, heap[i]);
}

/** PRINT **/
void print() {
    ofstream fout(OUTPUT);
    fout << sol;
    fout.close();
}

/** MAIN **/
int main() {
    read();
    solve();
    print();
    return 0;
}
