#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    if(sz > 2) {
        suka(l, sz / 2);
        suka(l+sz/2, r - 1);
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    if(n % 2 == 0) a[n] = 0;
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    while(l + 2 < r) {
        //print(l, " ", r, " ", prefsum[r] - prefsum[l], " ", prefsum[l+3] - prefsum[l], "\n");
        num sz = r - l;
        if(sz <= 1) return;
        sum += prefsum[r] - prefsum[l];
        sum += prefsum[l+3] - prefsum[l];
        l += 3;
        r -= 1;
    }
    sum += prefsum[r] - prefsum[l];

};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    if(n % 2 == 0) a[n] = 0;
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num k;
    while(l + 2 < r) {
        num sz = r - l;
        k = sz <= 4? 2: 3;
        //print(l, " ", r, " ", prefsum[r] - prefsum[l], " ", prefsum[l+k] - prefsum[l], "\n");
        if(sz <= 1) return;
        if(l < r) sum += prefsum[r] - prefsum[l];
        if(l + k < r) sum += prefsum[l+k] - prefsum[l];
        l += k;
        r -= 1;
    }
    if(l + 1 < r) sum += prefsum[r] - prefsum[l];
    //print(l, " ", r, "\n");

};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    //if(n % 2 == 0) a[n] = 0;
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    num szd3 = sz / 3;
    if(sz >= 4) {
        if(szd3 <= 2) {
            suka(l, l + sz / 2);
            suka(l + sz / 2, r - 1);
        } else {
            suka(l, l + szd3);
            suka(l + szd3, l + szd3 * 2);
            suka(l + szd3 * 2, r);
        }
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
        prefsum[i+1] = prefsum[i] + a[i];
    }
    sort(begin(a), begin(a) + n);
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num n, i;
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    num sum = 0;
    _for(i,0,n) {
        get(a[i]);
        sum += a[i];
    }
    sort(begin(a), begin(a) + n);
    //_for(i,0,n) print(a[i], " "); print("\n");
    num k = 0;
    while(n > 1) {

        if(n >= 3) {
            k += sum;
            sum -= a[n - 1] + a[n - 2];
            //print(a[n-1], " ", a[n-2], "\n");
            n -= 2;
        } else {
            k += sum;
            sum -= a[n - 1];
            //print(a[n-1], "\n");
            n -= 1;
        }
    }
    print(k, "\n");
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    while(l + 2 < r) {
        //print(l, " ", r, " ", prefsum[r] - prefsum[l], " ", prefsum[l+3] - prefsum[l], "\n");
        num sz = r - l;
        if(sz <= 1) return;
        sum += prefsum[r] - prefsum[l];
        if(l + 3 < r) sum += prefsum[l+3] - prefsum[l];
        l += 3;
        r -= 1;
    }
    if(l < r) sum += prefsum[r] - prefsum[l];
    //print(l, " ", r, "\n");

};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    if(n % 2 == 0) a[n] = 0;
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    num szd3 = sz / 3;
    if(sz >= 4) {
        if(szd3 <= 2) {
            if(sz == 4) {
                suka(l, l + 2);
            } else {
                suka(l, l + 3);
                num e = (l + 6 > r)? r: l + 6;
                suka(l + 3, e);
                suka(e, r);
            }
        } else {
            suka(l, l + szd3);
            suka(l + szd3, l + szd3 * 2);
            suka(l + szd3 * 2, r);
        }
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    num szd3 = sz / 3;
    if(sz >= 4) {
        if(szd3 <= 2) {
            if(sz > 6) {
                sz -= 3;
                suka(l, l + sz / 2);
                suka(l + sz / 2, r - 3);
                suka(r - 3, 3);
            } else {
                suka(l, l + sz / 2);
                suka(l + sz / 2, r - 1);
            }
        } else {
            suka(l, l + szd3);
            suka(l + szd3, l + szd3 * 2);
            suka(l + szd3 * 2, r);
        }
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
        prefsum[i+1] = prefsum[i] + a[i];
    }
    sort(begin(a), begin(a) + n);
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    num szd3 = sz / 3;
    if(sz >= 4) {
        if(szd3 <= 2) {
            if(sz == 4) {
                suka(l, l + 2);
            } else if(sz == 6) {
                suka(l, l + 3);
                suka(l + 3, r - 1);
            } else {
                suka(l, l + 3);
                num e = (l + 6 > r)? r: l + 6;
                suka(l + 3, e);
                suka(e, r);
            }
        } else {
            suka(l, l + szd3);
            suka(l + szd3, l + szd3 * 2);
            suka(l + szd3 * 2, r);
        }
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    num szd3 = sz / 3;
    if(sz >= 4) {
        if(szd3 <= 2) {
            if(sz == 4) {
                suka(l, l + 2);
            } else if(sz == 6) {
                suka(l, l + 3);
                suka(l + 3, r - 1);
            } else {
                suka(l, l + 3);
                num e = (l + 6 > r)? r: l + 6;
                suka(l + 3, e);
                suka(e, r);
            }
        } else {
            suka(r - szd3, r);
            suka(r - szd3 * 2, r - szd3);
            suka(l, r - szd3 * 2);
        }
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    num szd3 = sz / 3;
    if(sz >= 4) {
        if(szd3 <= 2) {
            if(sz == 4) {
                suka(l, l + 2);
            } else {
                suka(l, l + 3);
                suka(l + 3, r - 1);
            }
        } else {
            suka(l, l + szd3);
            suka(l + szd3, l + szd3 * 2);
            suka(l + szd3 * 2, r);
        }
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num n, i;
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    num sum = 0;
    _for(i,0,n) {
        get(a[i]);
        sum += a[i];
    }
    sort(begin(a), begin(a) + n);
    //_for(i,0,n) print(a[i], " "); print("\n");
    num k = 0, i0 = 0, in = n-1;
    while(n > 1) {
        k += sum;
        if(n == 2) {
            sum -= a[in];
            //print(a[in], "\n");
            n -= 1;
            in -= 1;
        } else if(n == 3) {
            sum -= a[in] + a[in - 1];
            n -= 2;
            in -= 2;
            //print(a[in], " ", a[in-1], "\n");
        } else if(n > 3) {
            sum -= a[i0] + a[i0 + 1] + a[in];
            k += a[i0] + a[i0 + 1];
            //print(a[i0], " ", a[i0+1], " ", a[in], "\n");
            i0 += 2;
            n -= 3;
            in -= 1;
        }
    }
    print(k, "\n");
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    num szd3 = sz / 3;
    if(sz >= 4) {
        if(szd3 <= 2) {
            suka(l, l + 3);
            suka(l + 3, r - 1);
        } else {
            suka(l, l + szd3);
            suka(l + szd3, l + szd3 * 2);
            suka(l + szd3 * 2, r);
        }
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long num;

inline void get(num& v) {
    bool f = false; char ch = getchar(); v = 0;
    while(ch < '0') f = (ch == '-'), ch = getchar();
    while(ch >= '0') v = v * 10 + ch - '0', ch = getchar();
    if(f) v = -v;
}
template <typename T>
void print(T t) { cout << t; }
template<typename T, typename... Args>
void print(T t, Args... args) { cout << t; print(args...); }
#define _for(i,s,e) for(i=s;i<e;i++)
#define _fok(i,s,e,k) for(i=s;i<e;i+=k)
//
// gi gi gi gi gi gi gi gi gi gi gi gi
//
const int SZ = 2e5 + 10;
num a[SZ];
num prefsum[SZ];
num n, i, sum = 0;
void suka(num l, num r) {
    num sz = r - l;
    if(sz <= 1) return;
    //print(l, " ", r, " ", prefsum[r] - prefsum[l], "\n");
    sum += prefsum[r] - prefsum[l];
    if(sz >= 4) {
        if(l + 3 < r) suka(l, l + 3);
        if(l + 6 < r) suka(l + 3, l + 6);
        if(l + 6 < r) suka(l + 6, r);
    }
};
int main() {
    #ifdef GIGI
        freopen("in", "r", stdin);
    #endif
    get(n);
    prefsum[0] = a[0];
    _for(i,0,n) {
        get(a[i]);
    }
    if(n % 2 == 0) {
        a[n] = 0;
        n++;
    }
    sort(begin(a), begin(a) + n);
    _for(i,0,n) prefsum[i+1] = prefsum[i] + a[i];
    suka(0, n);
    print(sum, "\n");
    //_for(i,0,n) print(prefsum[i], " "); print("\n");
    /*num k = 0, i0 = 0, in = n-1;
    num suka = log(n) / log(3);
    num d1 = n - n % (num)pow(3, suka);
    num d2 = n - d1;
    print(d1, " ", d2, "\n");*/
}


#include <iostream>

using namespace std;

int a[2*10^6+5];

int main()
{
    int n,sol=0,sum=0;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin >>a[i];
        sum+=a[i];
    }
    sol = sum;
    //cout << sum<<endl;
    if (n==3 || n==2) { cout << sum; return 0;}

    while (n>3) {
        sum -= a[n-1]+a[n-2];
        n -= 2;
        sol += sum;
        cout << "sol: "<<sol<<endl;
    }
    //sol += sum;
    cout << sol;
    return 0;
}


#include <iostream>

using namespace std;

int a[2*10^6+5];

int main()
{
    int n,sol=0,sum=0;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin >>a[i];
        sum+=a[i];
    }
    sol = sum;
    //cout << sum<<endl;
    if (n==3 || n==2) { cout << sum; return 0;}

    while (n>3) {
        sum -= a[n-1]+a[n-2];
        n -= 2;
        sol += sum;
        //cout << "sol: "<<sol<<endl;
    }
    //sol += sum;
    cout << sol;
    return 0;
}


//============================================================================
// Name        : CF884D.cpp
// Author      : rand0m
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <queue>
#include <stdio.h>
#include <vector>

using namespace std;

template<typename T> void print_queue(T& q) {
    while(!q.empty()) {
        std::cout << q.top() << " ";
        q.pop();
    }
    //std::cout << '\n';
}

int main()
{
    int n,sol=0,p,x;
    scanf("%d",&n);
    priority_queue<int, vector<int>, greater<int> > q;
    for (int i=0; i<n; i++)
    {
    	scanf("%d",&p);
    	q.push(p);
    }
    if (!(q.size() & 1)) q.push(0);

    //print_queue(q);

    while (q.size() > 1) {
    	x = q.top();
    	q.pop();
    	//print_queue(q); printf(" - %d \n",q.size());
    	x += q.top();
    	q.pop();
    	x += q.top();
    	q.pop();

    	q.push(x);
    	sol += x;

    }
    cout << sol;
    return 0;
}


//============================================================================
// Name        : CF884D.cpp
// Author      : rand0m
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <queue>
#include <stdio.h>
#include <vector>

using namespace std;

template<typename T> void print_queue(T& q) {
    while(!q.empty()) {
        std::cout << q.top() << " ";
        q.pop();
    }
    //std::cout << '\n';
}

int main()
{
    int n,p;
    long long sol=0,x;
    scanf("%d",&n);
    priority_queue<long long, vector<long long>, greater<long long> > q;
    for (int i=0; i<n; i++)
    {
    	scanf("%d",&p);
    	q.push(p);
    }
    if (!(q.size() & 1)) q.push(0);

    while (q.size() > 1) {
    	x = q.top();
    	q.pop();
    	x += q.top();
    	q.pop();
    	x += q.top();
    	q.pop();

    	q.push(x);
    	sol += x;

    }
    cout << sol;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int noColors ;

priority_queue < int ,  vector < int > > allBile ;

int sol ;

int main(){

    scanf("%d",&noColors );

    if ( noColors %2 == 0 ){
        allBile.push( 0 );
    }

    for ( int i = 0 ; i < noColors ; i++ ){
        int x ;
        scanf("%d",&x);

        allBile.push( -x );

    }

    while ( allBile.size() >= 3 ){
        int val1 = -allBile.top() ;
        allBile.pop();
        int val2 = -allBile.top() ;
        allBile.pop();
        int val3 = -allBile.top() ;
        allBile.pop();

        val1 += val2 + val3 ;

        sol += val1 ;

        allBile.push( -val1 );

    }

    if ( allBile.size() != 1 ){
        while ( !allBile.empty() ){

            sol += allBile.top() ;
            allBile.pop() ;

        }
    }

    printf("%d",sol);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int noColors ;

priority_queue < int ,  vector < int > > allBile ;

int sol ;

int main(){

    scanf("%d",&noColors );

    if ( noColors %2 == 0 ){
        allBile.push( 0 );
    }

    for ( int i = 0 ; i < noColors ; i++ ){
        int x ;
        scanf("%d",&x);

        allBile.push( -x );

    }

    while ( allBile.size() >= 3 ){
        int val1 = -allBile.top() ;
        allBile.pop();
        int val2 = -allBile.top() ;
        allBile.pop();
        int val3 = -allBile.top() ;
        allBile.pop();

        val1 += val2 + val3 ;

        sol += val1 ;

        allBile.push( -sol );

    }

    if ( allBile.size() != 1 ){
        while ( !allBile.empty() ){

            sol += allBile.top() ;
            allBile.pop() ;

        }
    }

    printf("%d",sol);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long noColors ;

priority_queue < long long ,  vector < long long > > allBile ;

long long sol ;

int main(){

    scanf("%I64d",&noColors );

    if ( noColors %2 == 0 ){
        allBile.push( 0 );
    }

    for ( long long i = 0 ; i < noColors ; i++ ){
        long long x ;
        scanf("%I64d",&x);

        allBile.push( -x );

    }

    while ( allBile.size() >= 3 ){
        long long val1 = -allBile.top() ;
        allBile.pop();
        long long val2 = -allBile.top() ;
        allBile.pop();
        long long val3 = -allBile.top() ;
        allBile.pop();

        val1 += val2 + val3 ;

        sol += val1 ;

        allBile.push( -val1 );

    }

    if ( allBile.size() != 1 ){
        while ( !allBile.empty() ){

            sol += allBile.top() ;
            allBile.pop() ;

        }
    }

    printf("%I64d",sol);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define lim           1000006
#define mod            100005
#define ll             long long
#define TestCase      int cases, tc; cin>>tc; for(cases=1; cases<=tc; cases++)
#define print         printf("Case %d: ",cases)
#define mem(a,v)        memset(a, v, sizeof(a))
#define pb             push_back
/**--------Loops--------------*/
#define frab(i, a, b)      for(__typeof(b) i=(a); i<=(b); i++)
#define fr0(i, n)          frab(i, 0, n-1)
#define fr1(i, n)          frab(i, 1, n)

int ans[11111];
int main()
{

  int a,b,n,i,j,m,k=0;

  cin>>a>>b>>n;
  int x= a%b;

  fr0(i,n)
  {
      ans[i]=-1;
    fr0(j,10)
    {
      if((x*10 +j) %b ==0)
      {
        ans[i]=j;
        x=0;
        break;
      }
    }
    if(ans[i]==-1) {cout<<-1<<endl; return 0;}
  }
   printf("%d", a);
  for (i=0;i<n;i++) printf("%d", ans[i]);
  printf("\n");
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define lim           1000006
#define mod            100005
#define ll             long long
#define TestCase      int cases, tc; cin>>tc; for(cases=1; cases<=tc; cases++)
#define print         printf("Case %d: ",cases)
#define mem(a,v)        memset(a, v, sizeof(a))
#define pb             push_back
/**--------Loops--------------*/
#define frab(i, a, b)      for(__typeof(b) i=(a); i<=(b); i++)
#define fr0(i, n)          frab(i, 0, n-1)
#define fr1(i, n)          frab(i, 1, n)

//int ans[11111];
int main()
{

  int a,b,n,i,j,m;

  cin>>a>>b>>n;
   m=a;

  fr0(i,n)
  {m=a;
    fr0(j,10)
    {
        m = m*10 + j;
       if(m%b==0) {a=m; break;}
       else m=a;
    }
  }
  cout<<a<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define lim           1000006
#define mod            100005
#define ll             long long
#define TestCase      int cases, tc; cin>>tc; for(cases=1; cases<=tc; cases++)
#define print         printf("Case %d: ",cases)
#define mem(a,v)        memset(a, v, sizeof(a))
#define pb             push_back
/**--------Loops--------------*/
#define frab(i, a, b)      for(__typeof(b) i=(a); i<=(b); i++)
#define fr0(i, n)          frab(i, 0, n-1)
#define fr1(i, n)          frab(i, 1, n)

//int ans[11111];
int main()
{

  int a,b,n,i,j,m,k=0;

  cin>>a>>b>>n;
   m=a;

  fr0(i,n)
  {m=a;
    fr0(j,10)
    {
        m = m*10 + j;
       if(m%b==0) {a=m;k=1; break;}
       else m=a;
    }
    if(k==0) {cout<<-1<<endl; return 0;}
  }
  //if(k)
  cout<<a<<endl;
  //else cout<<
}


#include<bits/stdc++.h>
using namespace std;
#define lim           1000006
#define mod            100005
#define ll             long long
#define TestCase      int cases, tc; cin>>tc; for(cases=1; cases<=tc; cases++)
#define print         printf("Case %d: ",cases)
#define mem(a,v)        memset(a, v, sizeof(a))
#define pb             push_back
/**--------Loops--------------*/
#define frab(i, a, b)      for(__typeof(b) i=(a); i<=(b); i++)
#define fr0(i, n)          frab(i, 0, n-1)
#define fr1(i, n)          frab(i, 1, n)

int ans[11111];
int main()
{

  int a,b,n,i,j,m,k=0;

  cin>>a>>b>>n;
  int x= a%b;

  fr0(i,n)
  {
      ans[i]=-1;
    fr0(j,10)
    {
      if((x*10 +j %b) ==0)
      {
        ans[i]=j;
        x=0;
        break;
      }
    }
    if(ans[i]==-1) {cout<<-1<<endl; return 0;}
  }
   printf("%d", a);
  for (i=0;i<n;i++) printf("%d", ans[i]);
  printf("\n");
  return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b,n;
cin >> a >> b >> n;
if (b ==10){
    cout << a ;
    for(int i =0 ; i< n ;i++)
        cout << 0 ;
    cout << endl;
    return 0;
}
if (b % 2 ==0){
  int z[]={2,4,6,8};
  vector<int> factors;
  for(int i =1 ; i< 10 ;i++)
    if (i % b ==0 || b % i==0) factors.push_back(i);
    if (factors.size() == 0){
        cout << -1 << endl;
        return 0;
    }
  for(int i =0; i< 4 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
else {
  int z[]={1,3,5,7,9};
  vector<int> factors;
  for(int i =1 ; i< 10 ;i++)
    if (i % b ==0 || b %i==0) factors.push_back(i);
     if (factors.size() == 0){
        cout << -1 << endl;
        return 0;
    }
  for(int i =0; i< 5 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main (){
int a,b,n;
cin >> a >> b >> n;
int d =a;
for(int i =0 ;i < n;i++){
    for(int j =9 ; j >=0;j--){
        if ((a*10+j) % b ==0 ){
            a = a*10+j;
            break;
        }
        //if (used > 0)
    }
}
if (d!=a)
cout << a << endl;
else
    cout << -1 << endl;
return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b,n;
cin >> a >> b >> n;
if (b ==10){
    cout << a ;
    for(int i =0 ; i< n ;i++)
        cout << 0 ;
    cout << endl;
    return 0;
}
if (b % 2 ==0){
  int z[]={2,4,6,8};
  vector<int> factors;
  for(int i =1 ; i< 10 ;i++)
    if (i % b ==0) factors.push_back(i);
    if (factors.size() == 0){
        cout << -1 << endl;
        return 0;
    }
  for(int i =0; i< 4 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
else {
  int z[]={1,3,5,7,9};
  vector<int> factors;
  for(int i =1 ; i< 10 ;i++)
    if (i % b ==0) factors.push_back(i);
     if (factors.size() == 0){
        cout << -1 << endl;
        return 0;
    }
  for(int i =0; i< 5 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b,n;
cin >> a >> b >> n;
if (b ==10){
    cout << a ;
    for(int i =0 ; i< n ;i++)
        cout << 0 ;
    cout << endl;
    return 0;
}
if (b % 2 ==0){
  int z[]={2,4,6,8};
  vector<int> factors;
  for(int i =1 ; i< b+1 ;i++)
    if (i % b ==0 ) factors.push_back(i);
    if (factors.size() == 0){
        cout << -1 << endl;
        return 0;
    }
  for(int i =0; i< 4 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
else {
  int z[]={1,3,5,7,9};
  vector<int> factors;
  for(int i =1 ; i< b+1 ;i++)
    if (i % b ==0 ) factors.push_back(i);
     if (factors.size() == 0){
        cout << -1 << endl;
        return 0;
    }
  for(int i =0; i< 5 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b,n;
cin >> a >> b >> n;
int d =a;
for(int i =0 ; i< 10;i++)
if (((a*10)+i)%b == 0){
    a = (a*10)+i;
    break;
}
if (a==d){
    cout << -1<< endl;
    return 0;
}
int k;
for(int i =0 ; i< 10;i++)
if (((a*10)+i)%b == 0){
    k = i;
    break;
}
cout << a;
for(int i =0 ; i< n-1 ;i++)
    cout << k;
cout << endl;
return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main (){
int a,b,n;
cin >> a >> b >> n;
int used,d =a;
for(int i =0 ;i < n;i++){
    for(int j =9 ; j >=0;j--){
        if ((a*10+j) % b ==0 && j != used){
            a = a*10+j;
            used = j;
            break;
        }
    }
}
if (d!=a)
cout << a << endl;
else
    cout << -1 << endl;
return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b,n;
cin >> a >> b >> n;

if (b == 10 ){
    cout << a;
    while(n--)
        cout << 0;
    cout << endl;
    return 0;
}

    int f1=-1,f2;
    for(int i = 1 ; i < 10 ;i++)
    if ( ((a*10)%b)==0){
        a = (a*10)+ i;
        break;
    }
    for(int i = 1 ; i < 10 ;i++)
    if ( ((a*10)+i)%b==0){
        f1=i;
        a = (a*10)+i;
        break;
    }
    if ( f1 == -1 ){
        cout << -1 << endl;
        return 0;
    }
  for(int i = 1 ; i < 10 ;i++)
    if ( ((a*10)+i)%b==0){
        f2=i;
        a = (a*10)+i;
        break;
    }
   // cout << f1 << f2 << endl;
    cout << a;
  for(int i =0 ;i < n-2 ; i++)
    cout << f2;
    cout << endl;

return 0;
}


#include<iostream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b,n;
cin >> a >> b >> n;
if (b %10 ==0){
    cout << a ;
    for(int i =0 ; i< n ;i++)
        cout << 0 ;
    cout << endl;
    return 0;
}
if (b % 2 ==0){
  int z[]={2,4,6,8};
  vector<int> factors;
  for(int i =1 ; i< 10 ;i++)
    if (i % b ==0) factors.push_back(i);
  for(int i =0; i< 4 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
else {
  int z[]={1,3,5,7,9};
  vector<int> factors;
  for(int i =1 ; i< 10 ;i++)
    if (i % b ==0) factors.push_back(i);
  for(int i =0; i< 5 ;i++){
    if (((a*10)+z[i]) % b == 0)
    {
        cout << (a*10)+z[i];
        break;
    }
  }
  for(int i =0 ; i < n-1;i++)
    cout << factors[0];
  cout << endl;
}
return 0;
}


#include <iostream>

using namespace std;

int main(){
  int a,b,n;
  cin >> a >> b >> n;
  int _a = a;
  if(b%2 == 0){
    for(int i=0;i<n;i++){
      for(int j=2;j<10;j+=2){
	if((a*10 + j)%b == 0){
	  a = a*10 + j;
	  break;
	}
      }
    }
  }
  else{
    for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
	if((a*10 + j)%b == 0){
	  a = a*10 + j;
	  break;
	}
      }
    }
  }
  if(a == _a)
    cout << -1;
  else
    cout << a;
  return 0;
}


#include <iostream>

using namespace std;

int main(){
  long long a,b,n;
  cin >> a >> b >> n;
  long long _a = a;
  string s = to_string(a);
  bool flag = false;
  if(b%2 == 0){
    for(long long i=0;i<n;i++){
      for(long long j=0;j<10;j+=2){
	if((a*10 + j)%b == 0){
	  s = s + to_string(j);
	  a = j;
	  flag = true;
	  break;
	}
      }
      if(!flag){
	cout << -1;
	return 0;
      }
    }
  }
  else{
    for(long long i=0;i<n;i++){
      for(long long j=0;j<10;j++){
	if((a*10 + j)%b == 0){
	  a = j;
	  s = s + to_string(j);
	  flag = true;
	  break;
	}
      }
      if(!flag){
	cout << -1;
	return 0;
      }
    }
  }
  cout << s;
  return 0;
}


#include <iostream>

using namespace std;

int main(){
  long long a,b,n;
  cin >> a >> b >> n;
  long long _a = a;
  if(b%2 == 0){
    for(long long i=0;i<n;i++){
      for(long long j=0;j<10;j+=2){
	if((a*10 + j)%b == 0){
	  a = a*10 + j;
	  break;
	}
      }
    }
  }
  else{
    for(long long i=0;i<n;i++){
      for(long long j=0;j<10;j++){
	if((a*10 + j)%b == 0){
	  a = a*10 + j;
	  break;
	}
      }
    }
  }
  if(a == _a)
    cout << -1;
  else
    printf("%I64d",a);
  return 0;
}


#include <iostream>

using namespace std;

int main(){
  long long a,b,n;
  cin >> a >> b >> n;
  long long _a = a;
  string s = to_string(a);
  bool flag = false;
  if(b%2 == 0){
    for(long long i=0;i<n;i++){
      flag = false;
      for(long long j=0;j<10;j+=2){
	if((a*10 + j)%b == 0){
	  s = s + to_string(j);
	  a = b;
	  flag = true;
	  break;
	}
      }
      if(!flag){
	cout << -1;
	return 0;
      }
    }
  }
  else{
    for(long long i=0;i<n;i++){
      flag = false;
      for(long long j=0;j<10;j++){
	if((a*10 + j)%b == 0){
	  a = b;
	  s = s + to_string(j);
	  flag = true;
	  break;
	}
      }
      if(!flag){
	cout << -1;
	return 0;
      }
    }
  }
  cout << s;
  return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    bool da=true;
    ll a,b,n, resto;
    cin>>a>>b>>n;
    for(int i=0;i<n;i++){
        resto = ((10*a)%b);
        if(resto == 0){
            a=10*a;
        }else{
            resto = b-resto;
            if(resto<10){
            a = (10*a)+resto;
        }else{
            da=false;
        }
        }
    }
    if(da){
        cout<<a<<endl;
    }else{
        cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    bool da=true;
    ll a,b,n, resto;
    cin>>a>>b>>n;
    for(int i=0;i<n;i++){
        resto = ((10*a)%b);
        resto = b-resto;
        if(resto<10){
            a = (10*a)+resto;
        }else{
            da=false;
        }
    }
    if(da){
        cout<<a<<endl;
    }else{
        cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    bool da;
    ll a,b,n, resto;
    cin>>a>>b>>n;
    for(int i=0;i<n;i++){
        resto = ((10*a)%b);
        resto = b-resto;
        if(resto<10){
            a = (10*a)+resto;
        }else{
            da=false;
        }
    }
    if(da){
        cout<<a<<endl;
    }else{
        cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define pb push_back
int main(){
    bool da=true;
    vector <int> resp;
    ll a,b,n, resto;
    cin>>a>>b>>n;
    resp.pb(a);
    for(int i=0;i<n;i++){
        resto = ((10*a)%b);
        //cout<<"resto eh"<<resto<<endl;
        if(resto == 0){
            a=resto;
            resp.pb(0);
        }else{
            resto = b-resto;
            if(resto<10){
            a = resto;
            resp.pb(resto);
        }else{
            da=false;
        }
        }
    }
    if(da){
        for(auto it=resp.begin();it!=resp.end();it++){
            cout<<(*it);
        }
        cout<<endl;
    }else{
        cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define pb push_back
int main(){
    bool da=true;
    vector <int> resp;
    ll a,b,n, resto, corrige;
    cin>>a>>b>>n;
    resp.pb(a);
    resto = a%b;
    for(int i=0;i<n;i++){
        resto = ((10*resto)%b);
        //cout<<"resto eh"<<resto<<endl;
        if(resto == 0){
            resp.pb(0);
            //cout<<"c1"<<endl;
        }else{
            corrige = b-resto;
            if(corrige<10){
            //cout<<"c2"<<corrige<<endl;
            resp.pb(corrige);
            resto = (resto+corrige)%b;
        }else{
            da=false;
        }
        }
    }
    if(da){
        for(auto it=resp.begin();it!=resp.end();it++){
            cout<<(*it);
        }
        cout<<endl;
    }else{
        cout<<-1<<endl;
    }
}


#include<stdio.h>
int main ()
{
    int a,b,n,x;
    scanf("%d %d %d", &a, &b, &n);
    for(x=0; x<n; x++){
            a=a*10;
        }
    for(x=0; x<=9; x++){
        a=a+x;
        if(a%b==0){
            printf("%d\n", a);
                break;
                }
        else{printf("-1\n");
                break;}}
    return 0;
}


#include<stdio.h>
int main ()
{
    unsigned long long a,b,n,c,d,x,y;
    scanf("%lld %lld %lld", &a, &b, &n);
    for(x=0; x<n; x++){
           c=a*10;
        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}
    if(a%b==0){
        printf("%lld\n", a);}

    else{printf("-1\n");}
    return 0;
}


#include<stdio.h>
int main ()
{
    long long a,b,n,c,d,x,y;
    scanf("%lld %lld %lld", &a, &b, &n);
    if(b==10){
   printf("%d", a);
   for(x=0; x<n; x++){
    printf("0");
   }
    }
    else{
    for(x=0; x<n; x++){
           c=a*10;
        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}
    if(a%b==0){
        printf("%lld\n", a);}

    else{printf("-1\n");}}
    return 0;
}


#include<stdio.h>
int main ()
{
    long long a,b,n,c,d,x,y;
    scanf("%lld %lld %lld", &a, &b, &n);
    for(x=0; x<n; x++){
           c=a*10;
        for(y=1; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}
    if(a%b==0){
        printf("%lld\n", a);}

    else{printf("-1\n");}
    return 0;
}


#include<stdio.h>
int main ()
{
    unsigned long long a,b,n,c,d,x,y;
    scanf("%lld %lld %lld", &a, &b, &n);
    if(b==10){
      for(x=0; x<n; x++){
        a=a*b;
    }}
    else{
    for(x=0; x<n; x++){
           c=a*10;
        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}}
    if(a%b==0){
        printf("%lld\n", a);}

    else{printf("-1\n");}
    return 0;
}


#include<stdio.h>
int main ()
{
    unsigned long long a,b,n,c,d,x,y;
    scanf("%lld %lld %lld", &a, &b, &n);
    if(b==10){
   printf("%d", a);
   for(x=0; x<n; x++){
    printf("0");
   }
    }
    else{
    for(x=0; x<n; x++){
           c=a*10;
        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}
    if(a%b==0){
        printf("%lld\n", a);}

    else{printf("-1\n");}}
    return 0;
}


#include<stdio.h>
int main ()
{
    unsigned long long a,b,n,c,d,x,y,z;
    scanf("%lld %lld %lld", &a, &b, &n);
    for(x=0; x<n; x++){
        x=x;
            if((a%b)==0){
                break;}
           c=a*10;

        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}

    if(a%b==0){
        printf("%lld", a);
        for(z=0; z<n-x; z++){
            printf("0");
        }}

    else{printf("-1\n");}
    return 0;
}


#include<stdio.h>
int main ()
{
    long long a,b,n,x;
    scanf("%lld %lld %lld", &a, &b, &n);
    for(x=0; x<n; x++){
            a=a*10;
        }
    for(x=0; x<=9; x++){
        a=a+x;
        if(a%b==0){
            printf("%lld\n", a);
                break;
                }
        else{printf("-1\n");
                break;}}
    return 0;
}


#include<stdio.h>
int main ()
{
    long long a,b,n,c,d,x,y;
    scanf("%lld %lld %lld", &a, &b, &n);
    for(x=0; x<n; x++){
           c=a*10;
        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}
    if(a%b==0){
        printf("%lld\n", a);}

    else{printf("-1\n");}
    return 0;
}


#include<stdio.h>
#include<math.h>
int main ()
{
    long long a,b,n,c,d,x,y;
    scanf("%lld %lld %lld", &a, &b, &n);
    if(b==10){
      for(x=0; x<n; x++){
        a=a*b;
    }}
    else{
    for(x=0; x<n; x++){
           c=a*10;
        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}}
    if(a%b==0){
        printf("%lld\n", a);}

    else{printf("-1\n");}
    return 0;
}


#include<stdio.h>
int main ()
{
    long long a,b,n,c,d,x,y,z;
    scanf("%lld %lld %lld", &a, &b, &n);
    for(x=0; x<n; x++){
        x=x;
            if((a%b)==0){
                break;}
           c=a*10;

        for(y=0; y<=9; y++){
            a=c+y;
                if((a%b)==0){
                break;
                }}}

    if(a%b==0){
        printf("%lld", a);
        for(z=0; z<n-x; z++){
            printf("0");
        }}

    else{printf("-1\n");}
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 1; i <= n; i++)

int main(){
	ios::sync_with_stdio(false);

	int a, b, n;
	cin >> a >> b >> n;

	int aux, flag;
	flag = 0;
	for(int i = 1; i <= 9; i++){
		aux = a*10+i;
		if(aux%b == 0){
			flag = 1;
			break;
		}
	}

	if(flag){
		printf("%d", aux);
		string intStr = to_string(aux);
		int tam = intStr.size();
		for(int i = 0; i <= n-tam; i++)
			printf("0");
		printf("\n");
	}
	else{
		printf("-1\n");
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 1; i <= n; i++)

int main(){
	ios::sync_with_stdio(false);

	int a, b, n;
	cin >> a >> b >> n;

	int aux, flag;
	flag = 0;
	for(int i = 0; i <= 9; i++){
		aux = a*10+i;
		//cout << aux << endl;
		if(aux%b == 0){
			flag = 1;
			break;
		}
	}

	if(flag){
		printf("%d", aux);
		for(int i = 0; i < n-1; i++)
			printf("0");
		printf("\n");

	}
	else{
		printf("-1\n");
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 1; i <= n; i++)

int main(){
	ios::sync_with_stdio(false);

	int a, b, n;
	cin >> a >> b >> n;

	int aux, flag;
	flag = 0;
	for(int i = 0; i <= 9; i++){
		aux = a*10+i;
		if(aux%b == 0){
			flag = 1;
			break;
		}
	}

	if(flag){
		string intStr = to_string(aux);
		int tam = intStr.size();
		for(int i = 0; i <= n; i++)
			if(i < tam)
				printf("%c",intStr[i]);
			else
				printf("0");
		printf("\n");
	}
	else{
		printf("-1\n");
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 1; i <= n; i++)

int main(){
	ios::sync_with_stdio(false);

	int a, b, n;
	cin >> a >> b >> n;

	int aux, flag;
	flag = 0;
	for(int i = 1; i <= 9; i++){
		aux = a*10+i;
		if(aux%b == 0){
			flag = 1;
			break;
		}
	}

	if(flag){
		printf("%d", aux);
		string intStr = to_string(aux);
		int tam = intStr.size();
		for(int i = 0; i < n-tam; i++)
			printf("0");
		printf("\n");
	}
	else{
		printf("-1\n");
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 1; i <= n; i++)

int main(){
	ios::sync_with_stdio(false);

	int a, b, n;
	cin >> a >> b >> n;

	int aux, flag;
	flag = 0;
	for(int i = 0; i <= 9; i++){
		aux = a*10+i;
		if(aux%b == 0){
			flag = 1;
			break;
		}
	}

	if(flag){
		printf("%d", aux);
		string intStr = to_string(aux);
		int tam = intStr.size();
		for(int i = 0; i < n-tam; i++)
			printf("0");
		printf("\n");
	}
	else{
		printf("-1\n");
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 1; i <= n; i++)

int main(){
	ios::sync_with_stdio(false);

	int a, b, n;
	cin >> a >> b >> n;

	int aux, flag;
	flag = 0;
	for(int i = 1; i <= 9; i++){
		aux = n*10+i;
		if(aux%b == 0){
			flag = 1;
			break;
		}
	}

	if(flag){
		printf("%d", aux);
		for(int i = 0; i < n-1; i++)
			printf("0");
		printf("\n");
	}
	else{
		printf("-1\n");
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 1; i <= n; i++)

int main(){
	ios::sync_with_stdio(false);

	int a, b, n;
	cin >> a >> b >> n;

	int aux, flag;
	flag = 0;
	for(int i = 0; i <= 9; i++){
		aux = a*10+i;
		if(aux%b == 0){
			flag = 1;
			break;
		}
	}

	if(flag){
		printf("%d", aux);
		string intStr = to_string(aux);
		int tam = intStr.size();
		for(int i = 0; i <= n-tam; i++)
			printf("0");
		printf("\n");
	}
	else{
		printf("-1\n");
	}

	return 0;

}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,j=1;
	ll a1=a;
	for (int j=0;j<=9;j++)
	{
		k=a*10+j;
		if(k%b==0)
		{
			printf("%d",k);
			for (int i=1;i<=n-1;i++)
			{
				printf("0");
			}
			return 0;
		}
//		printf("%lld\n",k);
//		if(check(k))
//		{
//			ll k1=k,t=0;
//			while(1)
//			{
//				k1=k1/10;
//				t++;
//				if(k1<1) break;
//			}
//			printf("%d",t);
//			if(t>n+1) break;
//			printf("%d",k);
//			for (int i=t+1;i<=n;i++)
//			{
//				printf("0");
//			}
//			return 0;
//		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,j=1;
	ll a1=a;
	while(1)
	{
		a1=a1/10;
		n++;
		if(a1<1) break;
	}
	//printf("%lld\n",n);
	for (int j=1;j<=100000;j++)
	{
		k=k+b;
		//printf("%lld\n",k);
		if(check(k))
		{
			ll k1=k,t=0;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			//printf("%d",t);
			if(t>n+1) break;
			printf("%d",k);
			for (int i=t+1;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,j=1;
	ll a1=a;
	while(1)
	{
		a1=a1/10;
		n++;
		if(a1<1) break;
	}
	//printf("%lld\n",n);
	for (int j=1;j<=10;j++)
	{
		k=k+b;
		//printf("%lld\n",k);
		if(check(k))
		{
			ll k1=k,t=0;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			//printf("%d",t);
			if(t>n+1) break;
			printf("%d",k);
			for (int i=t+1;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,t=1,j=1;
	for (int j=1;j<=1000;j++)
	{
		k=k+b;
		if(check(k))
		{
			ll k1=k;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			if(t>=n+1) break;
			printf("%d",k);
			for (int i=t-1;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,j=1;
	ll a1=a;
	while(1)
	{
		a1=a1/10;
		n++;
		if(a1<1) break;
	}
	//printf("%lld\n",n);
	for (int j=1;j<=10000;j++)
	{
		k=k+b;
		//printf("%lld\n",k);
		if(check(k))
		{
			ll k1=k,t=0;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			//printf("%d",t);
			if(t>n+1) break;
			printf("%d",k);
			for (int i=t+1;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,j=1;
	ll a1=a;
	while(1)
	{
		a1=a1/10;
		n++;
		if(a1<1) break;
	}
	for (int j=1;j<=1000;j++)
	{
		k=k+b;
		if(check(k))
		{
			ll k1=k,t=0;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			if(t>n+1) break;
			printf("%d",k);
			for (int i=t+1;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,t=1,j=1;
	for (int j=1;j<=1000;j++)
	{
		k=k+b;
		if(check(k))
		{
			ll k1=k;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			printf("%d",k);
			for (int i=t;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,t=1,j=1;
	for (int j=1;j<=1000;j++)
	{
		k=k+b;
		if(check(k))
		{
			ll k1=k;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			if(t>n+1) break;
			printf("%d",k);
			for (int i=t-1;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 100000007
using namespace std;
ll a,b,n,z=1;
bool check(ll k)
{
	ll w=1;
	while(1)
	{
		if(k/w==a) return 1;
		else
		{
			if(w>k) return 0;
			w=w*10;
		}
	 }
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	ll k=b;
	ll i=n,t=1,j=1;
	for (int j=1;j<=1000;j++)
	{
		k=k+b;
		if(check(k))
		{
			ll k1=k;
			while(1)
			{
				k1=k1/10;
				t++;
				if(k1<1) break;
			}
			printf("%d",k);
			for (int i=t-1;i<=n;i++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<cstdio>
using namespace std;
const int N=;
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	for(int i=0;i<=9;i++)
	{
		if(a*10+i)%b==0)
		{
			printf("%d",a*10+i);
			for(int i=1;i<n;i++)
				printf("0");
			return 0;
		}
	}
	return 0;
}
/*

*/


#include<cstdio>
using namespace std;
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	for(int i=0;i<=9;i++)
	{
		if(a*10+i)%b==0)
		{
			printf("%d",a*10+i);
			for(int i=1;i<n;i++)
				printf("0");
			return 0;
		}
	}
	return 0;
}
/*

*/


#include<cstdio>
using namespace std;
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	for(int i=0;i<=9;i++)
	{
		if((a*10+i)%b==0)
		{
			printf("%d",a*10+i);
			for(int i=1;i<n;i++)
				printf("0");
			return 0;
		}
	}
	return 0;
}
/*

*/


#include<cstdio>
using namespace std;
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	for(int i=0;i<=9;i++)
	{
		if((a*10+i)%b==0)
		{
			printf("%d",a*10+i);
			for(int j=1;j<n;j++)
				printf("0");
			return 0;
		}
	}
	printf("-1");
	return 0;
}
/*

*/


#include<bits/stdc++.h>
#define fori  for(int i=0;i<n;i++)
using namespace std;

int main()
{
    int a, b, n;
    cin >> a >> b >> n;
    int c=0;
  for(int i=0;i<n;i++)
  {
        for(int j=0;j<9;j++)
        {
              if((a*10+j)%b==0)
              {
                    a=a*10+j;
                    c++;
                    break;
              }

        }
  }
  if(c==n)
  cout<<a;
  else
  cout<<-1;
}


#include<bits/stdc++.h>
#define fori  for(int i=0;i<n;i++)
using namespace std;

int main()
{
    int a, b, n;
    cin >> a >> b >> n;
    int c=0;
  for(int i=0;i<n;i++)
  {
        for(int j=0;j<9;j++)
        {
              if((a*10+j)%b==0)
              {
                    a=a*10+j;
                    c++;
                    break;
              }

        }
  }
  if(c==n)
  cout<<
  else
  cout<<-1;
}


#include<bits/stdc++.h>
#define fori  for(int i=0;i<n;i++)
using namespace std;

int main()
{
    int a, b, n;
    cin >> a >> b >> n;
    int f=0;
    string s;
    for(int j=0;j<=9;j++)
        {
              if((a*10+j)%b==0)
              {
                    a=a*10+j;

              cout<<a;
              string s(n-1,'0');
              cout<<s<<"\n";
              f++;
              break;
              }
        }

 if(f==0)
  cout<<-1;
}


#include<bits/stdc++.h>
#define fori  for(int i=0;i<n;i++)
using namespace std;

int main()
{
    int a, b, n;
    cin >> a >> b >> n;
    int f=0;
    string s;
    for(int j=0;j<9;j++)
        {
              if((a*10+j)%b==0)
              {
                    a=a*10+j;

              cout<<a;
              string s(n-1,'0');
              cout<<s<<"\n";
              f++;
              break;
              }
        }

 if(f==0)
  cout<<-1;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,flag=1;
    int n,z;
    //int x=,y=b-'1',z;
    string str,si;

    cin>>a>>b>>n;

    for(int i=0;i<9;i++){
        z=a%b;
        if((z*10+i)%b==0){
                cout<<a*10+i;
        string s(n-1,'0');
        cout<<s<<endl;
            flag=0;
            break;
        }
    }

   // s+=si;
   //cout<<x<<y<<endl;

    if(flag==1) cout<<-1<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    int n,z;
    //int x=,y=b-'1',z;
    string str,si;

    cin>>a>>b>>n;
    cout<<a;
    for(int i=0;i<9;i++){
        z=a%b;
        if((z*10+i)%b==0){
            cout<<i;

            break;
        }
    }
   // s+=si;
   //cout<<x<<y<<endl;
    string s(n-1,'0');
    cout<<s<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,flag=1;
    int n,z;
    //int x=,y=b-'1',z;
    string str,si;

    cin>>a>>b>>n;

    for(int i=0;i<9;i++){
        z=a%b;
        if((z*10+i)%b==0){
                cout<<a;
            cout<<i;
        string s(n-1,'0');
        cout<<endl;
            flag=0;
            break;
        }
    }

   // s+=si;
   //cout<<x<<y<<endl;

    if(flag==1) cout<<-1<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,flag=1;
    int n,z;
    //int x=,y=b-'1',z;
    string str,si;

    cin>>a>>b>>n;

    for(int i=0;i<=9;i++){
        z=a%b;
        if((z*10+i)%b==0){
                cout<<a*10+i;
        string s(n-1,'0');
        cout<<s<<endl;
            flag=0;
            break;
        }
    }

   // s+=si;
   //cout<<x<<y<<endl;

    if(flag==1) cout<<-1<<endl;

}


#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int main()
{
    int a,b,n,num,temp;
    cin>>a>>b>>n;
    for(int j=1;j<=n;j++)
    {
        a*=10;
        for(int i=1;i<=9;i++)
        {

            if((a+i)%b==0 && i!=temp)
            {
                a+=i;
                temp=i;
                break;
            }
            else if((a+i)%b!=0 && i==9)
            {
                a=-1;
                break;
            }

        }
    }
    cout<<a;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int main()
{
    long long a,b,n;
    cin>>a>>b>>n;
    for(int j=1;j<=n;j++)
    {
        a*=10;
        for(int i=0;i<=9;i++)
        {

            if((a+i)%b==0)
            {
                a+=i;

                break;
            }
            else if((a+i)%b!=0 && i==9)
            {
                a=-1;
                break;
            }

        }
    }
    cout<<a;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int main()
{
    long long int  a,b,n;
    cin>>a>>b>>n;
    n--;
    bool x(0);

        a*=10;
        for(int i=0;i<=9;i++)
        {

            if((a+i)%b==0)
            {

                x=1;
                break;
            }

        }
    if(x){
    cout<<a;
    while(n--)
    {
        cout<<0;
    }
    }else
    cout<<-1;
    return 0;
}


#include <cstdio>

int main(){

    long a,b,n; scanf("%ld %ld %ld", &a, &b, &n);
    bool possible(0);
    a *= 10; for(int k = 0; k < 10; k++){if((a + k)% b == 0){a += k; possible = 1; break;}}
    if(possible){printf("%ld",a); while(--n){printf("0");}; printf("\n");}
    else{puts("-1");}
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int main()
{
    long long int  a,b,n;
    cin>>a>>b>>n;
    n--;
    bool x(0);

        a*=10;
        for(int i=0;i<=9;i++)
        {

            if((a+i)%b==0)
            {
                a+=i;
                x=1;
                break;
            }

        }
    if(x){
    cout<<a;
    while(n--)
    {
        cout<<0;
    }
    }else
    cout<<-1;
    return 0;
}


//special judge!!!
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int a,b,n; cin>>a>>b>>n;
    int tag = 0;
    a *= 10;
    tag = 0;
    int i = 0;
    for(i=0;i<=9;i++) {
        if((a+i)%b==0) {
            tag = 1;
            break;
        }
    }
    if(tag == 0) cout<<-1<<endl;
    else {
        cout<<a/10<<i;
        for(int i=1;i<n;i++) cout<<0;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,n;
int main()
{
    cin>>a>>b>>n;
    bool f=0;
    for (int i=0; i<10;++i)
    {
        if ((a*10+i)%b==0)
        {
            printf("%d", a*10+i);
            for (int j=1;j<n;++j)
            {
                printf("0");
            }
            return 0;
        }
    }
    printf("-1");
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,n,i,t=1;
	cin>>a>>b>>n;
	for(i=0;i<=9;i++)
		if((a*10+i)%b==0){
			t=0;
			a=a*10+i;
			break;
		}
	if(t)cout<<"-1";
	else{
		cout<<a;
		for(i=1;i<n;i++)
			cout<<0;
	}
}


#include <bits/stdc++.h>
using namespace std;
int a,b,n;

int main()
{
	cin>>a>>b>>n;
	for(int i=0;i<=9;i++)
	{
		if(((a*10)+i)%b==0)
		{
			cout<<a*10+i;
			for(int j=1;j<=n-1;j++) cout<<0;
			return 0;
		}
	}
	cout<<-1;
    return 0;
}


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

int a,b,n;
int main()
{
    cin>>a>>b>>n;
    f(i,0,9)
    {
        if((a*10+i)%b == 0)
        {
            cout<<a*10+i;
            f(int j=1;j<=n-1,j++)
			cout<<"0";

            return 0;
        }

    }
    cout<<"-1"<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int b,n,x;
long long a;
int main()
{
	cin>>a>>b>>n;
	for(int i=1;i<=n;i++)
	{
		x=0;
		for(int j=1;j<=9;j++)
		{
			if((a*10+j)%b==0)
			{
				a*=10;
				a+=j;
				x=1;
				break;
			}
		}
		if(x==0)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	cout<<a<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,n,i,j;
	cin>>a>>b>>n;
	for(i=1;i<=n;i++)
		for(j=0;j<=9;j++)
			if((a*10+j)%b==0){
				a=a*10+j;
				break;
			}
	cout<<a;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b>10)
	{
		int x=(a*10+10)%b;
		if(x>10){
			printf("-1");
			return 0;
		}
		else{
			if(x==0){
				printf("-1");
				return 0;
			}
			else{
				cout<<a;
				cout<<10-x;
			}

		}
		if(c>1){
			for(int i=1;i<=c-1;i++){
				printf("0");
			}
		}
	}
	else if(b==10)
	{
		cout<<a;
		for(int i=1;i<=c;i++){
			printf("0");
		}
	}
	else{
		int x=(a*10+10)%b;
		cout<<a;
		if(x==0){
			cout<<10-b;
		}
		else{
			cout<<10-x;
		}
		for(int i=1;i<=c-1;i++)
		{
			cout<<b;
		}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
ll a,b,n;
ll cur;
int main()
{
	cin>>a>>b>>n;
	int flag = 0;
	for(int i = 0; i<=9; i++) {
		cur = a*10+i;
		if(cur%b == 0) {
			flag = 1;
			break;
		}
	}
	if(flag == 0) {
		puts("-1");return 0 ;
	}
	n--;
	printf("%lld",cur);
	for(int i = 1; i<=n; i++) putchar('0');
	return 0 ;
 }


#include<bits/stdc++.h>
using namespace std;
int a,b,n;
int main(){
    scanf("%d%d%d",&a,&b,&n);
    for(int i=0;i<=9;i++){
        int x=10*a+i;
        if(x%b==0){
            printf("%d",x);
            for(int j=1;j<=n-1j++)
                printf("0");
            return 0;
        }
    }
    printf("-1");
}


#include<stdio.h>
using namespace std;
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	for(int i=0;i<=9;i++)
	{
		if((10*a+i)%b==0)
		{
			printf("%d%d",a,i);
			for(int j=0;j<n-1;j++)
			{
				printf("0");
			}
			return 0;
		}
	}
	printf("-1");
	return 0;
}


#include<iostream>
using namespace std;

long a,b,n;

int main(){
	cin>>a>>b>>n;
	long i;
	for(i=0;i<10;i++){
		if((a*10+i)%b==0){
			cout<<a*10+i;
			n--;
			while(n--){
				cout<<0;
			}
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long a,b,n;
int main(){
	cin>>a>>b>>n;
	for(int i=0;i<=9;i++){
		if((a*10+i)%b==0){
			cout<<a*10+i;
			for(int j=1;j<=n-1;j++){
				cout<<'0';
			}
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}


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

int main()
{
  int A,B,N;
  cin>>A>>B>>N;
  int Temp=A;
  static int Ans[100000];
  for(int i=0;i<N;i++)
    {
      Ans[i]=-1;
      for(int j=0;j<10;j++)
        if(!((A*10+j)%B))
          Ans[i]=j;
      if(Ans[i]==-1)
        {
         cout<<"-1"<<endl;
          return 0;
        }
      A=0;
    }
  cout<<Temp<<endl;
  for(int i=0;i<N;i++)
    putchar(Ans[i]+48);
  putchar('\n');
  return 0;
}


#include<iostream>
using namespace std;
int main(){
	long long a, b, n, l0,ret;
	cin>>a>>b>>n;l0=n;
	if(b>10 && n>1) cout<<-1<<endl;
	else {
		bool can=0;
		for(long long i=0;i<=10;i++)
		{
			long long t=a*10+i;
			if(t%b==0)
			{
				can=1;
				cout<<a<<i;
				break;
			}
		}
		if(can) {
			l0--;
			while(l0--)
			{
				cout<<0;
			}
			cout<<endl;
		}
		else cout<<-1<<endl;
	}
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000010
using namespace std;
int a,b,n;
int main()
{
	bool flag=0;
	cin >> a >> b >> n;
	n--;
	for(int i=0;i<10;i++)
	{
		if((a*10+i)%b==0)
		{
			flag=1;
			a=a*10+i;
			break;
		}
	}
	if(!flag)
	{
		puts("-1");
		return 0;
	}
	cout << a;
	for(int i=1;i<=n;i++) cout << 0;
	return 0;
}


#include<iostream>
#define f(i,a,b) for(int i = a; i <= b ; i  ++ )
using namespace std;
int a,b,n;
int main()
{
    cin>>a>>b>>n;
    f(i,0,9)
    {
        if((a*10+i)%b==0)
        {
            cout<<a*10+i;
            f(j,1,n-1)cout<<"0";
            system("pause");
            return 0;
        }

    }
    cout<<"-1"<<endl;
    system("pause");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mod (int) 998244353
#define MOD (int) 1e9+7
#define X 1001100011100001111ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
#define vii vector<ii>
#define sz(s) s.size()
#define bits(n) __builtin_popcount(n)

const int MAXN = (int)((1e5) + 100);
int gcd(int a, int b)
{
    if (a == 0) return b;
    return gcd(b % a, a);
}

int cuberoot(int x)
{
    int lo = 1, hi = min(2000000ll, x);
    while (hi - lo > 1)
    {
        int mid = (lo + hi) / 2;
        if (mid * mid * mid < x)
        {
            lo = mid;
        }
        else hi = mid;
    }
    if (hi * hi * hi <= x) return hi;
    else return lo;
}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int N =  (int)(1 * 1e6 + 10);
bool comp(pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2)
{
    if (p1.fi > p2.first) return true;
    else if (p1.se == p2.se)
    {
        if (p1.se.fi < p2.se.fi) return true;
    }
    return false;
}

signed main()
{

    int a,b,n;
    cin>>a>>b>>n;

    int check=0;

        for(int i=0; i<9; i++)
        {
            if((a*10+i)%b==0)
            {
                cout<<a<<i;
                check=1;
                break;
            }
        }

    if(check)
        for(int i=1; i<n; i++)
            cout<<0;
    else
        cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;
#define mod (int) 998244353
#define MOD (int) 1e9+7
#define X 1001100011100001111ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
#define vii vector<ii>
#define sz(s) s.size()
#define bits(n) __builtin_popcount(n)

const int MAXN = (int)((1e5) + 100);
int gcd(int a, int b)
{
    if (a == 0) return b;
    return gcd(b % a, a);
}

int cuberoot(int x)
{
    int lo = 1, hi = min(2000000ll, x);
    while (hi - lo > 1)
    {
        int mid = (lo + hi) / 2;
        if (mid * mid * mid < x)
        {
            lo = mid;
        }
        else hi = mid;
    }
    if (hi * hi * hi <= x) return hi;
    else return lo;
}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int N =  (int)(1 * 1e6 + 10);
bool comp(pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2)
{
    if (p1.fi > p2.first) return true;
    else if (p1.se == p2.se)
    {
        if (p1.se.fi < p2.se.fi) return true;
    }
    return false;
}

signed main()
{

    int a,b,n;
    cin>>a>>b>>n;

    int check=0;

        for(int i=0; i<=9; i++)
        {
            if((a*10+i)%b==0)
            {
                cout<<a<<i;
                check=1;
                break;
            }
        }

    if(check)
        for(int i=1; i<n; i++)
            cout<<0;
    else
        cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;
#define mod (int) 998244353
#define MOD (int) 1e9+7
#define X 1001100011100001111ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
#define vii vector<ii>
#define sz(s) s.size()
#define bits(n) __builtin_popcount(n)

const int MAXN = (int)((1e5) + 100);
int gcd(int a, int b)
{
    if (a == 0) return b;
    return gcd(b % a, a);
}

int cuberoot(int x)
{
    int lo = 1, hi = min(2000000ll, x);
    while (hi - lo > 1)
    {
        int mid = (lo + hi) / 2;
        if (mid * mid * mid < x)
        {
            lo = mid;
        }
        else hi = mid;
    }
    if (hi * hi * hi <= x) return hi;
    else return lo;
}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int N =  (int)(1 * 1e6 + 10);
bool comp(pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2)
{
    if (p1.fi > p2.first) return true;
    else if (p1.se == p2.se)
    {
        if (p1.se.fi < p2.se.fi) return true;
    }
    return false;
}

signed main()
{

    int a,b,n;
    cin>>a>>b>>n;

    int check=0;
    for(int i=0; i<9; i++)
    {
        if((a*10+i)%b==0)
        {
            cout<<a<<i;
            check=1;
        }
    }

    if(check)
    for(int i=1;i<n;i++)
    cout<<0;
    else
    cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;
#define mod (int) 998244353
#define MOD (int) 1e9+7
#define X 1001100011100001111ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
#define vii vector<ii>
#define sz(s) s.size()
#define bits(n) __builtin_popcount(n)

const int MAXN = (int)((1e5) + 100);
int gcd(int a, int b)
{
    if (a == 0) return b;
    return gcd(b % a, a);
}

int cuberoot(int x)
{
    int lo = 1, hi = min(2000000ll, x);
    while (hi - lo > 1)
    {
        int mid = (lo + hi) / 2;
        if (mid * mid * mid < x)
        {
            lo = mid;
        }
        else hi = mid;
    }
    if (hi * hi * hi <= x) return hi;
    else return lo;
}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int N =  (int)(1 * 1e6 + 10);
bool comp(pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2)
{
    if (p1.fi > p2.first) return true;
    else if (p1.se == p2.se)
    {
        if (p1.se.fi < p2.se.fi) return true;
    }
    return false;
}

signed main()
{

    int a,b,n;
    cin>>a>>b>>n;

    int check=0;
    for(int i=0; i<n; i++)
    {
        if((a*10+i)%b==0)
        {
            cout<<a<<i;
            check=1;
        }
    }

    if(check)
    for(int i=1;i<n;i++)
    cout<<0;
    else
    cout<<-1;
}


#include <bits/stdc++.h>
using namespace std;
#define mu  1000000007
#define ll  long long int
#define vec vector< long long int>
#define pb  push_back
#define mk  make_pair
#define forn(a,b) for(int a=0;a<b;a++)
#define MAX 100001
#define INF INT_MAX
#define yes cout<<"YES\n"
#define no  cout <<"NO\n"
#define ull unsigned long long int
#define all(x) begin(x),end(x)
ll gcd(ll a, ll b){
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
bool cmp(const pair<int,int > &a,const pair<int,int> &b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first<b.first;
}
int main()
{
	int a,b,n;
	string s;
	cin>>a>>b>>n;
	s=to_string(a);
	bool flag1=0;
	while(n--)
	{
		bool flag=0;
		string temp;
		for(char i='0';i<'9';i++)
		{
			temp=s;
			temp+=i;
			ll t=stoi(temp);
			if(t%b==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			flag1=1;
			break;
		}
		else
		{
			s=temp;
		}
	}
	if(flag1==1)
		cout<<-1;
	else
		cout<<s;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mu  1000000007
#define ll  long long int
#define vec vector< long long int>
#define pb  push_back
#define mk  make_pair
#define forn(a,b) for(int a=0;a<b;a++)
#define MAX 100001
#define INF INT_MAX
#define yes cout<<"YES\n"
#define no  cout <<"NO\n"
#define ull unsigned long long int
#define all(x) begin(x),end(x)
ll gcd(ll a, ll b){
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
bool cmp(const pair<int,int > &a,const pair<int,int> &b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first<b.first;
}
int main()
{
	int a,b,n;
	string s;
	cin>>a>>b>>n;
	s=to_string(a);
	bool flag1=0;
	ll pos=0;
	if(b==10)
	{
		cout<<a;
		for(int i=0;i<n;i++)
			cout<<0;
	}
	else{
	while(n--)
	{
		bool flag=0;
		string temp;
		for(char i='0';i<='9';i++)
		{
			temp=s;
			temp+=i;
			ll t=stoi(temp);
			if(t%b==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			flag1=1;
			break;
		}
		else
		{
			s=temp;
			if(stoi(s)%10==0)
			{
				pos=n;
				break;
			}
		}
	}
	if(flag1==1)
		cout<<-1;
	else
	{
		for(int i=0;i<s.size();i++)
			cout<<s[i];
		for(int i=0;i<pos;i++)
			cout<<0;
	}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mu  1000000007
#define ll  long long int
#define vec vector< long long int>
#define pb  push_back
#define mk  make_pair
#define forn(a,b) for(int a=0;a<b;a++)
#define MAX 100001
#define INF INT_MAX
#define yes cout<<"YES\n"
#define no  cout <<"NO\n"
#define ull unsigned long long int
#define all(x) begin(x),end(x)
ll gcd(ll a, ll b){
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
bool cmp(const pair<int,int > &a,const pair<int,int> &b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first<b.first;
}
int main()
{
	int a,b,n;
	string s;
	cin>>a>>b>>n;
	s=to_string(a);
	bool flag1=0;
	while(n--)
	{
		bool flag=0;
		string temp;
		for(char i='0';i<'9';i++)
		{
			temp=s;
			temp+=i;
			int t=stoi(temp);
			if(t%b==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			flag1=1;
			break;
		}
		else
		{
			s=temp;
		}
	}
	if(flag1==1)
		cout<<-1;
	else
		cout<<s;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mu  1000000007
#define ll  long long int
#define vec vector< long long int>
#define pb  push_back
#define mk  make_pair
#define forn(a,b) for(int a=0;a<b;a++)
#define MAX 100001
#define INF INT_MAX
#define yes cout<<"YES\n"
#define no  cout <<"NO\n"
#define ull unsigned long long int
#define all(x) begin(x),end(x)
ll gcd(ll a, ll b){
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
bool cmp(const pair<int,int > &a,const pair<int,int> &b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first<b.first;
}
int main()
{
	int a,b,n;
	string s;
	cin>>a>>b>>n;
	s=to_string(a);
	bool flag1=0;
	if(b==10)
	{
		cout<<a;
		for(int i=0;i<n;i++)
			cout<<0;
	}
	else{
	while(n--)
	{
		bool flag=0;
		string temp;
		for(char i='0';i<'9';i++)
		{
			temp=s;
			temp+=i;
			ll t=stoi(temp);
			if(t%b==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			flag1=1;
			break;
		}
		else
		{
			s=temp;
		}
	}
	if(flag1==1)
		cout<<-1;
	else
		cout<<s;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mu  1000000007
#define ll  long long int
#define vec vector< long long int>
#define pb  push_back
#define mk  make_pair
#define forn(a,b) for(int a=0;a<b;a++)
#define MAX 100001
#define INF INT_MAX
#define yes cout<<"YES\n"
#define no  cout <<"NO\n"
#define ull unsigned long long int
#define all(x) begin(x),end(x)
ll gcd(ll a, ll b){
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
bool cmp(const pair<int,int > &a,const pair<int,int> &b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first<b.first;
}
int main()
{
	int a,b,n;
	string s;
	cin>>a>>b>>n;
	s=to_string(a);
	bool flag1=0;
	ll pos=0;
	if(b==10)
	{
		cout<<a;
		for(int i=0;i<n;i++)
			cout<<0;
	}
	else{
	while(n--)
	{
		bool flag=0;
		string temp;
		for(char i='0';i<'9';i++)
		{
			temp=s;
			temp+=i;
			ll t=stoi(temp);
			if(t%b==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			flag1=1;
			break;
		}
		else
		{
			s=temp;
			if(stoi(s)%10==0)
			{
				pos=n;
				break;
			}
		}
	}
	if(flag1==1)
		cout<<-1;
	else
	{
		for(int i=0;i<s.size();i++)
			cout<<s[i];
		for(int i=0;i<pos;i++)
			cout<<0;
	}
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

// #define int long long
typedef long long ll;

int MOD = 100000;

signed main()  {
	cin.tie(0);
	ios::sync_with_stdio(false);
    long long a, b, n, ans = 0, tmp;
    bool flag = true;

    cin >> a >> b >> n;

    a *= 10;

    for (int num = 0; num < 10; num++) {
        if (((a + num) % b) == 0) {
            string ans = to_string(a + num);
            for (int i = 0; i < n - 1; i++) {
                ans += "0";
            }
            cout << ans << endl;
            return 0;
        }
    }
        cout << -1 << endl;

}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

// #define int long long
typedef long long ll;

int MOD = 100000;

signed main()  {
	cin.tie(0);
	ios::sync_with_stdio(false);
    long long a, b, n, ans = 0, tmp;
    bool flag = true;

    cin >> a >> b >> n;

    a *= 10;

    for (int num = 0; num < 10; num++) {
        if (((a + num) % b) == 0) {
            string ans = to_string(a);
            for (int i = 0; i < n - 1; i++) {
                ans += "0";
            }
            cout << ans << endl;
            return 0;
        }
    }
        cout << -1 << endl;

}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

// #define int long long
typedef long long ll;

int MOD = 1000000007;

signed main()  {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b, n, ans = 0, tmp;
    bool flag = true;

    cin >> a >> b >> n;

    for (int i = 0; i < n; i++) {
        tmp = a*10 + b;
        int div = tmp/b;
        if (b*div < tmp - 10) {
            flag = false;
            break;
        }
        else {
           tmp = div * b;
           a = tmp;
        }
    }

    if (flag == false) {
        cout << -1 << endl;
    }
    else {
        cout << tmp << endl;
    }
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

// #define int long long
typedef long long ll;

int MOD = 100000;

signed main()  {
	cin.tie(0);
	ios::sync_with_stdio(false);
    long long a, b, n, ans = 0, tmp;
    bool flag = true;

    cin >> a >> b >> n;

    a *= 10;

    for (int num = 0; num < 10; num++) {
        if (((a + num) % b) == 0) {
            string ans = to_string(a);
            for (int i = 0; i < n - 1; i++) {
                ans += "0";
            }
            cout << ans << endl;
        }
        else {
            flag = false;
            break;
        }
    }
    if (flag == false) {
    }
        cout << -1 << endl;

}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

// #define int long long
typedef long long ll;

int MOD = 100000;

signed main()  {
	cin.tie(0);
	ios::sync_with_stdio(false);
    long long a, b, n, ans = 0, tmp;
    bool flag = true;

    cin >> a >> b >> n;

    for (int i = 0; i < n; i++) {
        tmp = a*10 + b;
        ll div = tmp/b;
        if (b*div < tmp - 10) {
            flag = false;
            break;
        }
        else {
           tmp = div * b;
           a = tmp;
        }
    }

    if (flag == false) {
        cout << -1 << endl;
    }
    else {
        cout << tmp << endl;
    }
}


/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define LL long long int
#define ULL unsigned LL

const int inf=1<<30;
const LL INF=1e18;
const int MOD=1e9+7;

int NextPrime(int n, int m)
{
    int b = -1;
    for(int p=n+1; p<=m; p++) {

        bool ok = false;
        for(int i=2; i*i<=p; i++)
        {
            if(p%i==0)
            {
                ok = true;
                break;
            }
        }
        if(!ok) return p;

    }
    //cout<<b<<endl;
    return b;
}

int main()
{
    int a, b, n;
    cin>>a>>b>>n;

    a *= 10;
    int c = b - (a%b);

    if(c<10 || (c==b && b==10))
    {
        if(c==10)
            c=0;
        cout<<a+c;

        for(int i=1; i<n; i++)
        {
            cout<<'0';
        }
        cout<<endl;
    }
    else cout<<-1<<endl;

    return 0;
}


/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define LL long long int
#define ULL unsigned LL

const int inf=1<<30;
const LL INF=1e18;
const int MOD=1e9+7;

int NextPrime(int n, int m)
{
    int b = -1;
    for(int p=n+1; p<=m; p++) {

        bool ok = false;
        for(int i=2; i*i<=p; i++)
        {
            if(p%i==0)
            {
                ok = true;
                break;
            }
        }
        if(!ok) return p;

    }
    //cout<<b<<endl;
    return b;
}

int main()
{
    int a, b, n;
    cin>>a>>b>>n;

    a *= 10;
    int c = b - (a%b);
    if(c<10 || a%b==0)
    {
        if(c>9)
            c=0;
        cout<<a+c;

        for(int i=1; i<n; i++)
        {
            cout<<'0';
        }
        cout<<endl;
    }
    else cout<<-1<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 100000000000000
//INF - 1e14
#define vi vector<ll>
#define PB push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define fer(i, a, n) for( ll i = a; i <= n; i++)
#define fdr(i, a, n) for( ll i = a; i >= n; i--)
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); fer(i,0,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); fer(i,0,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll> > v(row, vector<ll>(col,val))
#define matrix vector<vector<ll> >
#define printpartition cout << "-------------------------------------------------------------" << endl;
#define printmat(mat,row,col) cout << #mat << "::" << endl; fer(i,0,row-1)fer(j,0,col-1)cout << mat[i][j] << " \n"[j == col-1]; printpartition;
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
ll fast_pow(ll base, ll exp, ll M = MOD) { base = base % M; ll result = 1; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % M; base = (base * base) % M; exp = exp / 2; } return result; }
ll modInverse(ll A, ll M = MOD) { return fast_pow(A, M - 2, M); } // only when M is prime
vector<ll> clr(100000);
vector<vector<ll> > adj(100000);

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	ll n, m;
	cin >> n >> m;
	fer(i, 0, n - 1) {
		cin >> clr[i];
		clr[i]--;
	}
	fer(i, 0, m - 1) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		adj[clr[v]].push_back(clr[u]);
		adj[clr[u]].push_back(clr[v]);
	}
	ll mx = 0, res = clr[0] + 1;
	for (int i = 0; i < 100000; i++) {
		if (adj[i].size() > mx) {
			res = i + 1;
			mx = adj[i].size();
		}
	}

	cout << res;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> clr(100000);
vector<vector<int> > adj(100000);
int main() {
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> clr[i];
		clr[i]--;
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		if (!binary_search(adj[clr[v]].begin(), adj[clr[v]].end(), clr[u]))
			adj[clr[v]].push_back(clr[u]);
		if (!binary_search(adj[clr[u]].begin(), adj[clr[u]].end(), clr[v]))
			adj[clr[u]].push_back(v);
	}
	int mx = 0, res = clr[0] + 1;
	for (int i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> clr(100000);
vector<set<int> > adj(100000);
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> clr[i];
		clr[i]--;
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		adj[clr[v]].insert(clr[u]);
		adj[clr[u]].insert(v);
	}
	int mx = 0, res = clr[0] + 1;
	for (int i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> clr(100000);;
vector<set<int> > adj(100000);
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> clr[i];
		clr[i]--;
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		adj[clr[v]].insert(clr[u]);
		adj[clr[u]].insert(clr[v]);
	}
	int mx = 0, res = clr[0] + 1;
	for (int i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> clr(100000);
vector<vector<int> > adj(100000);
int main() {
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> clr[i];
		clr[i]--;
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		if (!binary_search(adj[clr[v]].begin(), adj[clr[v]].end(), clr[u]))
			adj[clr[v]].push_back(clr[u]);
		if (!binary_search(adj[clr[u]].begin(), adj[clr[u]].end(), clr[v]))
			adj[clr[u]].push_back(clr[v]);
	}
	int mx = 0, res = clr[0] + 1;
	for (int i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 100000000000000
//INF - 1e14
#define vi vector<ll>
#define PB push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define fer(i, a, n) for( ll i = a; i <= n; i++)
#define fdr(i, a, n) for( ll i = a; i >= n; i--)
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); fer(i,0,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); fer(i,0,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll> > v(row, vector<ll>(col,val))
#define matrix vector<vector<ll> >
#define printpartition cout << "-------------------------------------------------------------" << endl;
#define printmat(mat,row,col) cout << #mat << "::" << endl; fer(i,0,row-1)fer(j,0,col-1)cout << mat[i][j] << " \n"[j == col-1]; printpartition;
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
ll fast_pow(ll base, ll exp, ll M = MOD) { base = base % M; ll result = 1; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % M; base = (base * base) % M; exp = exp / 2; } return result; }
ll modInverse(ll A, ll M = MOD) { return fast_pow(A, M - 2, M); } // only when M is prime
vector<ll> clr(100000);
vector<vector<ll> > adj(100000);

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	ll n, m;
	cin >> n >> m;
	fer(i, 0, n - 1) {
		cin >> clr[i];
		clr[i]--;
	}
	fer(i, 0, m - 1) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		adj[clr[v]].push_back(clr[u]);
		adj[clr[u]].push_back(clr[v]);
	}
	// for (int i = 0; i < 8; i++) {
	// 	cout << i << "->";
	// 	for (auto j : adj[i]) {
	// 		cout << j << ", ";
	// 	}
	// 	cout << endl;
	// }
	ll mx = 0, res = clr[0];
	for (int i = 0; i < 100000; i++) {
		if (adj[i].size() > mx) {
			res = i + 1;
			mx = adj[i].size();
		}
	}

	cout << res;
	return 0;
}