#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll totalLength = 0;
    rep(i, n) totalLength += a[i];
    ll idealLength = totalLength / (n + k);
    if (totalLength % (n + k) != 0)
        ++idealLength;
    ll min = idealLength;
    ll max = 2 * idealLength;
    bool switcher = true;
    bool switcher2 = true;
    while (true)
    {
        ll presentLogsCount = 0;
        rep(i, n)
        {
            presentLogsCount += a[i] / idealLength;
            if (a[i] % idealLength != 0)
                ++presentLogsCount;
        }
        // if (presentLogsCount == (n + k))
        // {
        //     break;
        // }
        // else if (presentLogsCount > (n + k))
        if (presentLogsCount > (n + k))
        {
            // if (idealLength == (idealLength + max) / 2)
            // {
            //     break;
            // }
            min = idealLength;
            if (switcher)
            {
                idealLength = (idealLength + max) / 2;
                switcher = false;
            }
            else
            {
                idealLength = (idealLength + max) / 2 + 1;
                switcher = true;
            }
        }
        else
        {
            // if (idealLength == (idealLength + min) / 2 || idealLength == (idealLength + min) / 2 + 1)
            if (min == max || min + 1 == max)
            {
                break;
            }
            if (switcher2)
            {
                max = idealLength;
                idealLength = (idealLength + min) / 2;

                switcher2 = false;
            }
            else
            {
                idealLength = (idealLength + min) / 2 + 1;
                switcher2 = true;
            }
        }
    }
    cout << idealLength  << endl;

    return 0;
}

Measured memory_bytes: 4348