#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<int char_size>
struct Suffix_Array{
    const string s;
    const int n, log_n;
    int m;
    vector<vector<int>> sa, ord;

    int log_2(int k){
        int ret = 0;
        while((1<<ret) < k) ret++;
        return ret;
    }

    Suffix_Array(const string &str) : s(str+'$'), n(sz(s)), log_n(log_2(n)){
        m = max(char_size, n);
        sa.assign(n, vector<int>(log_n+1));
        ord.assign(n, vector<int>(log_n+1));
        vector<int> cnt(m, 0);

        rep(i, n) cnt[s[i]]++;
        rep(i, m-1) cnt[i+1] += cnt[i];
        rep(i, n) sa[--cnt[s[i]]][0] = i;
        ord[sa[0][0]][0] = 0;
        rep2(i, 1, n-1){
            int a = sa[i-1][0], b = sa[i][0];
            ord[b][0] = ord[a][0] + (s[a] < s[b]);
        }
        fill(all(cnt), 0);

        vector<int> tmp(n);
        rep(k, log_n){
            rep(i, n) tmp[i] = sa[i][k]+(n-(1<<k)), tmp[i] %= n;
            rep(i, n) cnt[ord[tmp[i]][k]]++;
            rep(i, m-1) cnt[i+1] += cnt[i];
            rep3(i, n-1, 0) sa[--cnt[ord[tmp[i]][k]]][k+1] = tmp[i];
            ord[sa[0][k+1]][k+1] = 0;
            rep2(i, 1, n-1){
                int a = sa[i-1][k+1], b = sa[i][k+1];
                pii p = {ord[a][k], ord[(a+(1<<k))%n][k]};
                pii q = {ord[b][k], ord[(b+(1<<k))%n][k]};
                ord[b][k+1] = ord[a][k+1] + (p < q);
            }
            fill(all(cnt), 0);
        }
    }

    int get_sa(int i) const {return sa[i][log_n];}

    int get_ord(int i) const {return ord[i][log_n];}

    void query(int l, vector<int> &SA, vector<int> &ORD){
        SA.resize(n), ORD.resize(n);
        vector<int> cnt(m, 0);
        int sum = 0;
        
        vector<int> tmp(n), memo(n);
        rep(k, log_n+1){
            if(!(l&(1<<k))) continue;
            if(sum == 0){
                rep(i, n) SA[i] = sa[i][k], ORD[i] = ord[i][k];
            }
            else{
                rep(i, n) tmp[i] = sa[i][k]+(n-sum), tmp[i] %= n;
                rep(i, n) cnt[ORD[tmp[i]]]++;
                rep(i, m-1) cnt[i+1] += cnt[i];
                rep3(i, n-1, 0) SA[--cnt[ORD[tmp[i]]]] = tmp[i];
                memo[SA[0]] = 0;
                rep2(i, 1, n-1){
                    int a = SA[i-1], b = SA[i];
                    pii p = {ORD[a], ord[(a+sum)%n][k]};
                    pii q = {ORD[b], ord[(b+sum)%n][k]};
                    memo[b] = memo[a] + (p < q);
                }
                swap(ORD, memo);
                fill(all(cnt), 0);
            }
            sum += 1<<k;
        }
    }
};

int main(){
    int K; string S;
    cin >> K >> S;
    int N = sz(S);
    int n = (N+K)/(K+1);
    int sum = N-(n-1)*(K+1);
    Suffix_Array<256> SA(S);
    vector<int> sa, ord;
    SA.query(n, sa, ord);
    int l = -1, r = N; //(l, r]
    while(r-l > 1){
        int m = (l+r)/2;
        int cnt = 0;
        for(int i = 0; i < N;){
            if(ord[i] <= ord[sa[m]] && i+n <= N) cnt++, i += n;
            else{
                if(n-1 > 0) i += n-1;
                else break;
            }
        }
        if(cnt >= sum) r = m;
        else l = m;
    }
    cout << S.substr(sa[r], n) << endl;
}

Measured memory_bytes: 25676