#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using pii = pair<int, int>;

struct Element {
    int req_R;    // Ceil(freq / alloc)
    int char_idx; // 0 to 25
    int alloc;    // Copies assigned
    int freq;     // Original frequency

    bool operator<(const Element& other) const {
        if (req_R != other.req_R) return req_R < other.req_R;
        return char_idx > other.char_idx;
    }
};

void solve() {
    int k;
    string s;
    if (!(cin >> k >> s)) return;

    vector<int> freq(26, 0);
    int distinct_cnt = 0;
    int first_char = -1;

    for (char c : s) {
        if (freq[c - 'a'] == 0) distinct_cnt++;
        freq[c - 'a']++;
    }

    if (k < distinct_cnt) {
        cout << "-1\n";
        return;
    }

    for (int i = 0; i < 26; i++) {
        if (freq[i] > 0) {
            first_char = i;
            break;
        }
    }

    priority_queue<Element> pq;
    int used_slots = 0;

    for (int i = 0; i < 26; i++) {
        if (freq[i] > 0) {
            int init_alloc = 1;
            int req_R = (freq[i] + init_alloc - 1) / init_alloc;
            pq.push({req_R, i, init_alloc, freq[i]});
            used_slots++;
        }
    }

    while (used_slots < k) {
        Element top = pq.top();

        int new_R = (top.freq + (top.alloc + 1) - 1) / (top.alloc + 1);

        if (new_R == top.req_R) {
            break; // Stop redistributing; assign remaining slots to smallest char
        }

        pq.pop();
        top.alloc++;
        top.req_R = new_R;
        pq.push(top);

        used_slots++;
    }

    vector<int> final_alloc(26, 0);
    while (!pq.empty()) {
        auto el = pq.top();
        pq.pop();
        final_alloc[el.char_idx] = el.alloc;
    }

    int extra = k - used_slots;
    if (extra > 0 && first_char != -1) {
        final_alloc[first_char] += extra;
    }

    string ans = "";
    for (int i = 0; i < 26; i++) {
        if (final_alloc[i] > 0) {
            ans.append(final_alloc[i], (char)('a' + i));
        }
    }

    cout << ans << "\n";
}

int main() {
    fastio;
    int t = 1;
    // cin >> t; // Uncomment if problem has multiple test cases
    while (t--) {
        solve();
    }
    return 0;
}