#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
int num[N];
int n;
bool judge(long long x){
	long long sum = 0;
	for(int i= 1;i <= n;i ++){
		if(x < num[i]) return false;
		sum += x - num[i];

	}
	//cout << sum <<  ' '<< n << endl;
	return sum >= x;
}

int main(){
	scanf("%d",&n);
	for(int i= 1;i <= n;i ++){
		scanf("%d",&num[i]);
	}
	long long l = 0,r = 1e10;
	while(r-l>1){
		long long mid = (l+r)>>1;
		if(judge(mid)){
			r = mid;
		}
		else l = mid;
	}
	cout << r << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
int num[N];
int n;
bool judge(long long x){
	long long sum = 0;
	for(int i= 1;i <= n;i ++){
		sum += x - num[i];
	}
	//cout << sum <<  ' '<< n << endl;
	return sum >= n;
}

int main(){
	scanf("%d",&n);
	for(int i= 1;i <= n;i ++){
		scanf("%d",&num[i]);
	}
	long long l = 0,r = 1e10;
	while(r-l>1){
		long long mid = (l+r)>>1;
		if(judge(mid)){
			r = mid;
		}
		else l = mid;
	}
	cout << r << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
int num[N];
int n;
bool judge(long long x){
	long long sum = 0;
	for(int i= 1;i <= n;i ++){
		if(x < num[i]) return false;
		sum += x - num[i];

	}
	//cout << sum <<  ' '<< n << endl;
	return sum >= n;
}

int main(){
	scanf("%d",&n);
	for(int i= 1;i <= n;i ++){
		scanf("%d",&num[i]);
	}
	long long l = 0,r = 1e10;
	while(r-l>1){
		long long mid = (l+r)>>1;
		if(judge(mid)){
			r = mid;
		}
		else l = mid;
	}
	cout << r << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
    int mx=0;

    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    if(sum/(n-1)==0)
        cout<<sum/(n-1);
    else cout<<sum/(n-1)+1;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
        int mx=0;
    for(int i=1;i<=n;i++)
    if(a[i]>mx)
    mx=a[i];
    cout<<mx+1;
}


#include<bits/stdc++.h>
using namespace std;
long long a[100005];
int main()
{
    int n;
    cin>>n;
    long long mx=0;

    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    cout<<max(mx,((sum-1)/(n-1)+1));
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
    int mx=0;

    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    if(sum%(n-1)==0)
        cout<<sum/(n-1);
    else cout<<sum/(n-1)+1;

}


#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
    int mx=0;

    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    cout<<sum/(n-1)+1;

}


#include<bits/stdc++.h>
using namespace std;
long long a[100005];
int main()
{
    int n;
    cin>>n;
    long long mx=0;

    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    cout<<max(mx,((sum)/(n-1)));
    return 0;

}


#include <bits/stdc++.h>
#define    ll      long long int
using namespace std ;
int main(){
  //  freopen("input.txt", "r", stdin);
    int n ;
    cin >> n ;
    set< pair<int , int > > st ;
    for( int i=0 ; i<n ; i++){
        int k ;
        cin >>  k ;
        st.insert(make_pair(k,i)) ;
    }
    int ans=0 ;
    while(1){
        set< pair<int,int> >::iterator it ;
        it = st.end() ;
        it-- ;
        int kk=0 ;
        kk = (*it).first ;
        if((*it).first<=ans){
            break ;
        }
        pair<int,int> p = *st.begin() ;                 //     cout<<"delete"<<p.first;
        it=st.begin() ;
        it++ ;
        int x = (*it).first - p.first + 1;                //cout<<"      x= "<<p.first+x<<"  max = "<<kk;
        if( p.first+x >= kk ){
            x-- ;
        }
        if(x==0){
            x++ ;
        }
        st.erase(p) ;                                       //   cout<<"   add   "<<x<<endl ;
        p.first+=x ;
        st.insert(p) ;
        ans+=x ;
    }
    cout<<ans<<endl ;
    return 0 ;
}


#include <bits/stdc++.h>
#define    ll      long long int
using namespace std ;
int main(){
    ios::sync_with_stdio(false) ;
  //  freopen("input.txt", "r", stdin);
    int n ;
    cin >> n ;
    set< pair<int , int > > st ;
    ll ans=0 ;
    ll realans=0 ;
    for( int i=0 ; i<n ; i++){
        ll k ;
        cin >>  k ;
        ans += k ;
        realans=max(realans,k) ;
        st.insert(make_pair(k,i)) ;
    }
    ll p =(ans+n-2)/(n-1) ;
    cout<<((realans>=p)?realans:p)<<endl;
    return 0 ;
}


#include <bits/stdc++.h>
#define    ll      long long int
using namespace std ;
int main(){
   // freopen("input.txt", "r", stdin);
    int n ;
    cin >> n ;
    set< pair<int , int > > st ;
    for( int i=0 ; i<n ; i++){
        int k ;
        cin >>  k ;
        st.insert(make_pair(k,i)) ;
    }
    int ans=0 ;
    while(1){
        set< pair<int,int> >::iterator it ;
        it = st.end() ;
        it-- ;
        int kk=0 ;
        kk = (*it).first ;
        if((*it).first<=ans){
            break ;
        }
        pair<int,int> p = *st.begin() ;                 //     cout<<"delete"<<p.first;
        it=st.begin() ;
        it++ ;
        int x = (*it).first - p.first ;                //cout<<"      x= "<<p.first+x<<"  max = "<<kk;
       // if( p.first+x >= kk ){
         //   x-- ;
        //}
        if(x==0){
            x++ ;
        }
        st.erase(p) ;                                       //   cout<<"   add   "<<x<<endl ;
        p.first+=x ;
        st.insert(p) ;
        ans+=x ;
    }
    cout<<ans<<endl ;
    return 0 ;
}


#include <bits/stdc++.h>
#define    ll      long long int
using namespace std ;
int main(){
    ios::sync_with_stdio(false) ;
   // freopen("input.txt", "r", stdin);
    int n ;
    cin >> n ;
    set< pair<int , int > > st ;
    for( int i=0 ; i<n ; i++){
        int k ;
        cin >>  k ;
        st.insert(make_pair(k,i)) ;
    }
    int ans=0 ;
    while(1){
        set< pair<int,int> >::iterator it ;
        it = st.end() ;
        it-- ;
        int kk=0 ;
        kk = (*it).first ;
        if((*it).first<=ans){
            break ;
        }
        pair<int,int> p = *st.begin() ;                 //     cout<<"delete"<<p.first;
        it=st.begin() ;
        it++ ;
        int x = (*it).first - p.first ;                //cout<<"      x= "<<p.first+x<<"  max = "<<kk;
        if(x==0){
            x++ ;
        }
        st.erase(p) ;                                       //   cout<<"   add   "<<x<<endl ;
        p.first+=x ;
        st.insert(p) ;
        ans+=x ;
    }
    cout<<ans<<endl ;
    return 0 ;
}


#include <bits/stdc++.h>
#define    ll      long long int
using namespace std ;
int main(){
    //freopen("input.txt", "r", stdin);
    int n ;
    cin >> n ;
    set< pair<int , int > > st ;
    for( int i=0 ; i<n ; i++){
        int k ;
        cin >>  k ;
        st.insert(make_pair(k,i)) ;
    }
    int ans=0 ;
    while(1){
        set< pair<int,int> >::iterator it ;
        it = st.end() ;
        it-- ;
        if((*it).first<=ans){
            break ;
        }
        pair<int,int> p = *st.begin() ;
        st.erase(p) ;
        p.first+=1 ;
        st.insert(p) ;
        ans++ ;
    }
    cout<<ans<<endl ;
    return 0 ;
}


#include <bits/stdc++.h>
#define    ll      long long int
using namespace std ;
int main(){
    //freopen("input.txt", "r", stdin);
    int n ;
    cin >> n ;
    set< pair<int , int > > st ;
    for( int i=0 ; i<n ; i++){
        int k ;
        cin >>  k ;
        st.insert(make_pair(k,i)) ;
    }
    int ans=0 ;
    while(1){
        set< pair<int,int> >::iterator it ;
        it = st.end() ;
        it-- ;
        if((*it).first<=ans){
            break ;
        }
        pair<int,int> p = *st.begin() ;
        it=st.begin() ;
        it++ ;
        int x = (*it).first - p.first + 1;
        st.erase(p) ;
        p.first+=x ;
        st.insert(p) ;
        ans+=x ;
    }
    cout<<ans<<endl ;
    return 0 ;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,maxx=-1,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        maxx=max(maxx,a[i]);
    }
    ll ans=maxx;
    if(sum%(n-1)==0)cout<<max(sum/(n-1),maxx)<<endl;
    else cout<<max(sum/(n-1)+1,maxx)<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,maxx=1e12;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        maxx=max(maxx,a[i]);
    }
    cout<<maxx+1<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll ans=a[0];
    for(int i=1;i<n;i++)
        ans+=(a[i]-a[i-1]);
    cout<<ans+1<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll ans=a[0];
    sort(a,a+n);
    for(int i=1;i<n;i++)
        ans+=(a[i]-a[i-1]);
    cout<<ans+1<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,maxx=-1;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        maxx=max(maxx,a[i]);
    }
    cout<<maxx+1<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

int a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]+1<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,minn=1e10;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        minn=min(minn,a[i]);
    }
    ll ans=0;
    for(int i=0;i<n;i++)
        ans+=(a[i]-minn);
    cout<<ans+minn+1<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]+1<<endl;
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=10000+10,inf=0x3f3f3f;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,minn=1e10;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        minn=min(minn,a[i]);
    }
    ll ans=0;
    sort(a,a+n);
    for(int i=1;i<n;i++)
        ans+=(a[i]-a[i-1]);
    cout<<ans+minn+1<<endl;
    return 0;
}


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

const int maxn = 112345;
#define LL long long
const LL INFF = 0x3f3f3f3f3f3fll;

LL arr[maxn];
int n;

bool check(LL x){
    LL ret = 0;
    for(int i = 0;i<n;i++){
        ret += x - arr[i];
    }
    return ret >= x;
}

LL cal(){
    LL st = *max_element(arr,arr+n),ed = INFF;
    LL ans = -1;
    while(st <= ed){
        LL mid = (st + ed)>>1;
        if(check(mid)){
            ans = mid;
            ed = mid - 1;
        }
        else{
            st = mid + 1;
        }
    }
    return ans;
}

int main(){
    scanf("%d",&n);
    for(int i = 0;i<n;i++){
        scanf("%I64d",&arr[i]);
    }
    printf("%I64d\n",cal());
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll a[100005];
bool check(ll l,ll r)
{
    ll mid=(l+r)/2;

}
int main()
{
    scanf("%I64d",&n);
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        sum+=a[i];
    }
    ll ge;
    if(sum%(n-1)==0)
        ge=sum/(n-1);
    else
        ge=sum/(n-1)+1;
    printf("%I64d\n",ge);
}


const int maxn = 112345;
#define LL long long
const LL INFF = 0x3f3f3f3f3f3fll;

LL arr[maxn];
int n;

bool check(LL x){
    LL ret = 0;
    for(int i = 0;i<n;i++){
        ret += x - arr[i];
    }
    return ret >= x;
}

LL cal(){
    LL st = *max_element(arr,arr+n),ed = INFF;
    LL ans = -1;
    while(st <= ed){
        LL mid = (st + ed)>>1;
        if(check(mid)){
            ans = mid;
            ed = mid - 1;
        }
        else{
            st = mid + 1;
        }
    }
    return ans;
}

int main(){
    scanf("%d",&n);
    for(int i = 0;i<n;i++){
        scanf("%I64d",&arr[i]);
    }
    printf("%I64d\n",cal());
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int MAXN = 1E5 + 100;
int n, a[MAXN], sum, ma;
bool check(ll mid)
{
    return n*mid-sum >= mid;
}

int main()
{
    cin >> n;
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        sum += a[i];
        ma = max(a[i], ma);
    }
    ll l = ma, r = 1e12, mid;
    while(l<r)
    {
        mid = (l+r)/2;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    cout << l << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int MAXN = 1E5 + 100;
int n, a[MAXN], sum, ma;
bool check(ll mid)
{
    return n*mid-sum >= mid;
}

int main()
{
    cin >> n;
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        sum += a[i];
        ma = max(a[i], ma);
    }
    ll l = ma, r = 1e13, mid;
    while(l<r)
    {
        mid = (l+r)/2;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    cout << l << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int MAXN = 1E5 + 100;
ll n, a[MAXN], sum, ma;
bool check(ll mid)
{
    return n*mid-sum >= mid;
}

int main()
{
    cin >> n;
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        sum += a[i];
        ma = max(a[i], ma);
    }
    ll l = ma, r = 1e12, mid;
    while(l<r)
    {
        mid = (l+r)/2;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    cout << l << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int MAXN = 1E5 + 100;
int n, a[MAXN];

int main()
{
    cin >> n;
    ll sum = 0;
    for(int i=0; i<n; ++i) cin >> a[i];
    for(int i=0; i<n; ++i) sum += a[i];
    ll ans = 0;
    ans = sum/(n-1);
    if(sum%(n-1)!=0) ans++;
    cout << ans << endl;

    return 0;
}


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

int main()
{
	int n;
	scanf("%d", &n);
	long long sum = 0, m = 0;
	for(int i=0; i<n; ++i){
		long long temp;
		scanf("%lld", &temp);
		sum += temp;
		m = max(m, temp);
	}
	long long  ans = sum / (n-1);
	if(sum % (n-1)) ++ans;
	cout<<max(ans, m)<<endl;
	return 0;
}


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

int a[100005];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		scanf("%d", a+i);
	}
	sort(a, a+n);
	if(a[n-1] - a[0] <= 1)
		printf("%d\n", a[n-1] + 1);
	else
		printf("%d\n", a[n-1]);
	return 0;
}


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

int a[100005];

int main()
{
	int n;
	for(int i=0; i<n; ++i){
		scanf("%d", a+i);
	}
	sort(a, a+n);
	if(a[n-1] - a[0] >= n-1)
		printf("%d\n", a[n-1]);
	else if(a[n-1] == a[0])
		printf("%d\n", a[n-1] + 1);
	return 0;
}


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

int a[100005];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		scanf("%d", a+i);
	}
	sort(a, a+n);
	if(a[n-1] - a[0] >= n-1)
		printf("%d\n", a[n-1]);
	else
		printf("%d\n", a[n-1] + 1);
	return 0;
}


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

int main()
{
	int n;
	scanf("%d", &n);
	int sum = 0, m = 0;
	for(int i=0; i<n; ++i){
		int temp;
		scanf("%d", &temp);
		sum += temp;
		m = max(m, temp);
	}
	int ans = sum / (n-1);
	if(sum % (n-1)) ++ans;
	printf("%d\n", max(ans, m));
	return 0;
}


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

int main()
{
	int n;
	scanf("%d", &n);
	int sum = 0;
	for(int i=0; i<n; ++i){
		int temp;
		scanf("%d", &temp);
		sum += temp;
	}
	int ans = sum / (n-1);
	if(sum % (n-1)) ++ans;
	printf("%d\n", ans);
	return 0;
}


#include<iostream>

using namespace std;

int n, a, ans, sum, mx;

int main()
{
	cin>> n;
	for(int i=0; i<n; i++)
	{
		cin>>a;
		sum+=a;
		mx= max(mx, a);
	}

	ans= (sum/(n-1))+1;

	cout<<max(mx, ans) <<endl;

	return 0;
}


#include<iostream>
#include<algorithm>

using namespace std;

int n, a, ans, sum, mx;

int main()
{
	cin>> n;
	for(int i=0; i<n; i++)
	{
		cin>>a;
		sum+=a;
		mx= max(mx, a);
	}

	ans= ((sum-1)/(n-1))+1;

	cout<<max(mx, ans) <<endl;

	return 0;
}


#include<iostream>
#include<algorithm>

using namespace std;

long long n, a, ans, sum, mx;

int main()
{
	cin>> n;
	for(int i=0; i<n; i++)
	{
		cin>>a;
		sum+=a;
		mx= max(mx, a);
	}

	ans= ((sum-1)/(n-1))+1;

	cout<<max(mx, ans) <<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define f first
#define s second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
typedef long long int ll;

int main()
{
    int n;cin>>n;
    int a[n];
    double sum=0;
    int maxi=-1;
    for(int i=0;i<n;i++)
    {  cin>>a[i];
    	sum+=a[i];
    	maxi=max(maxi,a[i]);
    }
    int ans=ceil(sum/((n-1)*(1.0)));

    cout<<max(ans,maxi)<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define f first
#define s second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
typedef long long int ll;

int main()
{
    int n;
    cin>>n;

    int a[n];
    ll sum=0;
    int maxi=-1;
    for(int i=0;i<n;i++)
    {  cin>>a[i];
    	sum+=a[i];
    	maxi=max(maxi,a[i]);

    }
    ll temp=ceil((sum+maxi)*(1.0)/n);
    ll ans;
    if(temp<maxi)
    	ans=n;
    else
    	ans=temp;
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define f first
#define s second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
typedef long long int ll;

int main()
{
    int n;
    cin>>n;

    int a[n];
    ll sum=0;
    int maxi=-1;
    for(int i=0;i<n;i++)
    {  cin>>a[i];
    	sum+=a[i];
    	maxi=max(maxi,a[i]);

    }
    //cout<<sum+maxi<<endl;
    ll temp=ceil((sum+maxi)*(1.0)/n);
    //cout<<temp<<endl;
    ll ans;
    if(temp<maxi)
    	ans=n;
    else
    {
    	ans=temp;
    	if((sum+maxi)%n==0)
         ans++;
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
//#define maxn 0x3f3f3f

using namespace std;

const int maxn=1e5+10;
int n;

int c[11];
int main(){
    while(cin>>n){//int x;
		//freopen("E:\\rush.txt", "r", stdin);
		long long x;//int atot=0,btot=0;bool ab=0;
		long long hh=0,ind=0;
		for(int i=1;i<=n;i++){
			cin>>x;
			ind+=x;hh=max(hh,x);
		}long long ans=ind;
		ans=ind/(n-1);
		if(ind%(n-1)!=0) ans++;
		if(ans<hh) ans=hh;
		cout<<ans<<endl;
		//else cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
//#define maxn 0x3f3f3f

using namespace std;

const int maxn=1e5+10;
int n;

int c[11];
int main(){
    while(cin>>n){//int x;
		//freopen("E:\\rush.txt", "r", stdin);
		int x;//int atot=0,btot=0;bool ab=0;
		long long hh=0,ind=0;
		for(int i=1;i<=n;i++){
			cin>>x;
			ind+=x;hh=max(hh,x);
		}long long ans=ind;
		ans=ind/(n-1);
		if(ind%(n-1)!=0) ans++;
		if(ans<hh) ans=hh;
		cout<<ans<<endl;
		//else cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
//#define maxn 0x3f3f3f

using namespace std;

const int maxn=1e5+10;
int n;

int c[11];
int main(){
    while(cin>>n){//int x;
		//freopen("E:\\rush.txt", "r", stdin);
		int x;//int atot=0,btot=0;bool ab=0;
		int hh=0,ind=0;
		for(int i=1;i<=n;i++){
			cin>>x;
			ind+=x;
		}int ans=ind;
		ans=ind/(n-1);
		if(ind%(n-1)!=0) ans++;
		cout<<ans<<endl;
		//else cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
//#define maxn 0x3f3f3f

using namespace std;

const int maxn=1e5+10;
int n;

int c[11];
int main(){
    while(cin>>n){//int x;
		//freopen("E:\\rush.txt", "r", stdin);
		int x;//int atot=0,btot=0;bool ab=0;
		long long hh=0,ind=0;
		for(int i=1;i<=n;i++){
			cin>>x;
			ind+=x;
		}long long ans=ind;
		ans=ind/(n-1);
		if(ind%(n-1)!=0) ans++;
		cout<<ans<<endl;
		//else cout<<ans<<endl;
    }
    return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;

ll ans, n, t;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	ans = n - 2;
	for (int i = 1; i <= n; i++)	cin >> t, ans += t;
	cout << ans / (n - 1);
	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const int MAXN = 1e5 + 10;

ll ans, n, a[MAXN];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)	cin >> a[i];
	sort(a + 1, a + n + 1);
	ans = a[1];
	ll t = ans, f = 0;
	for (int i = n - 1; i >= 2 and t > 0 and a[n] > 0; i--) {
		a[i] -= f;
		a[i] = max(a[i], 0LL);
		ll k = min(t, a[n] - a[i]);
		if (k <= 0)
			break;
		else
			f += k, a[n] -= k, t -= k;
	}
	ans += a[n];
	cout << ans;
	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const int MAXN = 1e5 + 10;

ll ans, n, a[MAXN];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)	cin >> a[i];
	sort(a + 1, a + n + 1);
	ans = a[1];
	ll t = ans, f = 0;
	for (int i = n - 1; i >= 2 and t > 0 and a[n] > 0; i--) {
		a[i] -= f;
		a[i] = max(a[i], 0LL);
		ll k = t / (n - i + 1);
		a[n] -= max(k, a[n] - a[i]);
		f += max(k, a[n] - a[i]);
		if (k == 0)
			break;
	}
	ans += a[n];
	cout << ans;
	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const int MAXN = 1e5 + 10;

ll ans, n, a[MAXN];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)	cin >> a[i];
	sort(a + 1, a + n + 1);
	ans = a[1];
	ll t = ans, f = 0;
	for (int i = n - 1; i >= 2 and t > 0 and a[n] > 0; i--) {
		a[i] -= f;
		a[i] = max(a[i], 0LL);
		ll k = min(t, a[n] - a[i]);
		f += k, a[n] -= k, t -= k;
	}
	if (t > 0) {
		a[n] -= ll(t / (n - 1)) * (n - 2) + ((t % (n - 1)) > 0 ? (t % (n - 1)) - 1 : 0);
	}
	ans += max(a[n], 0LL);
	cout << ans;
	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const int MAXN = 1e5 + 10;

ll n, a[MAXN], ans;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)	cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = n - 1; i >= 1; i--) {
		a[i] = max(0LL, a[i] - ans);
		ans += a[i + 1] - a[i];
	}
	ans += ll(a[1] / (n - 1)) * (n - 1);
	a[1] = a[1] % (n - 1);
	ans += a[1] + 1;
	cout << ans;
	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;

ll n, t, mx;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)	cin >> t, mx = max(mx, t);
	cout << mx + 1;
	return 0;
}


import java.util.*;
import java.io.*;
/*
 * author:yanghui
 */
public class A {

	class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader() throws FileNotFoundException {
			reader = new BufferedReader(new FileReader("d:/input.txt"));
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}

	public void run() {

		InputReader reader = new InputReader(System.in);
		int n = reader.nextInt();
		int a[] = new int[n];
		int max = -1;
		for(int i = 0 ; i < n ; i ++){
			a[i] = reader.nextInt();
			max = Math.max(max, a[i]);
		}
		System.out.println(max + 1);
	}

	public static void main(String args[]) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;
/*
 * author:yanghui
 */
public class A {

	class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader() throws FileNotFoundException {
			reader = new BufferedReader(new FileReader("d:/input.txt"));
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}

	public void run() {

		InputReader reader = new InputReader(System.in);
		int n = reader.nextInt();
		int a[] = new int[n];
		long sum = 0;
		for(int i = 0 ; i < n ; i ++){
			a[i] = reader.nextInt();
			sum += (long)a[i];
		}
		long ans = sum / (n-1);
		if(sum % (n-1) != 0)
			ans ++;
		System.out.println(ans);
	}

	public static void main(String args[]) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;
/*
 * author:yanghui
 */
public class A {

	class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader() throws FileNotFoundException {
			reader = new BufferedReader(new FileReader("d:/input.txt"));
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}

	public void run() {

		InputReader reader = new InputReader(System.in);
		int n = reader.nextInt();
		int a[] = new int[n];
		long sum = 0;
		for(int i = 0 ; i < n ; i ++){
			a[i] = reader.nextInt();
			sum += (long)a[i];
		}
		long ans = sum / (long)(n-1);
		if(sum % (n-1) != 0)
			ans ++;
		System.out.println(ans);
	}

	public static void main(String args[]) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;
/*
 * author:yanghui
 */
public class A {

	class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader() throws FileNotFoundException {
			reader = new BufferedReader(new FileReader("d:/input.txt"));
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}

	public void run() {

		InputReader reader = new InputReader(System.in);
		int n = reader.nextInt();
		int a[] = new int[n];
		long sum = 0;
		for(int i = 0 ; i < n ; i ++){
			a[i] = reader.nextInt();
			sum += (long)a[i];
		}
		long ans = sum / 2 + sum % 2;
		System.out.println(ans);
	}

	public static void main(String args[]) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;
/*
 * author:yanghui
 */
public class A {

	class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader() throws FileNotFoundException {
			reader = new BufferedReader(new FileReader("d:/input.txt"));
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}

	public void run() {

		InputReader reader = new InputReader(System.in);
		int n = reader.nextInt();
		int a[] = new int[n];
		long sum = 0;
		long max = -1;
		for(int i = 0 ; i < n ; i ++){
			a[i] = reader.nextInt();
			sum += (long)a[i];
			max = Math.max(max, a[i]);
		}
		long ans = sum / (long)(n-1);
		if(sum % (n-1) != 0)
			ans ++;
		ans = Math.max(ans, max);
		System.out.println(ans);
	}

	public static void main(String args[]) {
		new A().run();
	}
}


import java.util.Scanner;
public class C16 {
    public static void main(String[] args) {
    Scanner sc=new Scanner (System.in);
 int n=sc.nextInt(); long s=0;for (int i=0;i<n;i++)s+=sc.nextInt();
 System.out.println(s%(n-1)==0?s/(n-1):s/(n-1)+1);
    }}


import java.util.Scanner;
public class C16 {
    public static void main(String[] args) {
    Scanner sc=new Scanner (System.in);
    int m=-1;
 int n=sc.nextInt(); long s=0;for (int i=0;i<n;i++){
     int t=sc.nextInt();
     if (t>m)m=t;
     s+=t;
 }
 long r=s%(n-1)==0?s/(n-1):s/(n-1)+1;
 if (r>=m)
 System.out.println(r);
 else System.out.println(m);
    }}


import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class C15 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int [n];
        for (int i=0;i<n;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        int b[]=new int [n];
        for (int i=0,j=n-1;i<n;i++,j--)b[i]=a[j];
        int k=b[n-2];
        int l=b[1];
        int r=b[n-1];
        if (b.length==3){
            l=l-=(b[0]%2==1?(b[0]/2)+1:b[0]/2);
            r-=b[0]/2;
            System.out.println(b[0]+Math.max(l,Math.max(r,0)));
            return;
        }
        long v=Long.MAX_VALUE;
        if (r<=b[0]/2){
            l=a[0]-r;
            if (l>0)v=b[0]+l;
        }
        r-=k/2+b[0]-k;
        l-=(k%2==1?(k/2)+1:k/2)+b[0]-k;
long ans=Math.min(v, b[0]+Math.max(l,Math.max(r,0)));
System.out.println(ans);

}
}


import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StreamCorruptedException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Solution
{
    public static void main(String[] args) {
        new Solution().solve();
    }

    PrintWriter out;
    int x;
    int[][] st,st1;
//    long mod=1000000007L ;
    public void solve()
    {
        out=new PrintWriter(System.out);
        int n=in.nextInt();
        long sum=0L;
        int max=0;
        for(int i=0;i<n;i++)
        {
            int t=in.nextInt();
            sum+=t;
            max=Math.max(max, t);
        }

        System.out.println(Math.max((long)(Math.ceil(((double)sum)/(n-1))),max));

        out.close();
    }

    public static int gcd(int a, int b) {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }
    class s implements Comparable<s>
    {
        int diff;
        int count=0;
        public s(int diff)
        {
            out.println("hello "+diff);
            this.diff=diff;
            count++;
        }

        public boolean equals(Object o)
        {
            if(o==null)
            {
                return false;
            }
            else
            {
                s o1=(s)o;
                if(this.diff==o1.diff)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        public int hashCode()
        {
            return diff;
        }

        @Override
        public int compareTo(s o) {
            // TODO Auto-generated method stu
            return this.diff-o.diff;
        }

    }

    FasterScanner in=new FasterScanner();

    public class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}


import java.util.*;
public class C{
    public static void main(String [] args){
        final Scanner s = new Scanner(System.in);
        final int n = s.nextInt();
        long sum = 0;
        long max = 0;
        for (int i = 0; i < n; ++i){
            final long a = s.nextLong();
            sum += a;
            max = Math.max(max, a);
        }
        final long res = Math.max(max, (sum + n - 2)/(n - 1));
        System.out.println(res);
        s.close();
    }
}


//package Round_202;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

    void solve() throws Exception{
        int n = in.nextInt();
        int a[] = new int[n];
        long sum = 0;
        for (int i = 0; i<n; i++){
            a[i] = in.nextInt();
            sum += a[i];
        }
        long ans = (sum / (n - 1)) + (sum % (n - 1) == 0 ? 0 : 1);
        out.println(ans);
    }

    String input = "";
    String output = "";
    FastScanner in;
    PrintWriter out;

    void run() throws Exception {
        if (input.length() == 0) {
            in = new FastScanner(System.in);
        } else {
            in = new FastScanner(new File(input));
        }
        if (output.length() == 0) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(new File(output));
        }

        solve();

        out.close();

    }

    public static void main(String[] args) throws Exception {
        new C().run();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            bf = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File fr) throws FileNotFoundException {
            bf = new BufferedReader(new FileReader(fr));
        }

        public String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(bf.readLine());
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


//package Round_202;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

    void solve() throws Exception{
        int n = in.nextInt();
        int a[] = new int[n];
        int min0 = Integer.MAX_VALUE;
        int min1 = Integer.MAX_VALUE;
        int ind0 = -1;
        int ind1 = -1;
        int max = 0;
        for (int i = 0; i<n; i++){
            a[i] = in.nextInt();
            if (a[i] <= min0){
                min1 = min0;
                min0 = a[i];
                ind1 = ind0;
                ind0 = i;
            } else if (a[i] < min1){
                min1 = a[i];
                ind1 = i;
            }
            max = Math.max(max, a[i]);
        }
        out.println(min0 + (max - min0) + 1);
    }

    String input = "";
    String output = "";
    FastScanner in;
    PrintWriter out;

    void run() throws Exception {
        if (input.length() == 0) {
            in = new FastScanner(System.in);
        } else {
            in = new FastScanner(new File(input));
        }
        if (output.length() == 0) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(new File(output));
        }

        solve();

        out.close();

    }

    public static void main(String[] args) throws Exception {
        new C().run();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            bf = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File fr) throws FileNotFoundException {
            bf = new BufferedReader(new FileReader(fr));
        }

        public String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(bf.readLine());
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


//package Round_202;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

    void solve() throws Exception{
        int n = in.nextInt();
        int a[] = new int[n];
        long sum = 0;
        int max = 0;
        for (int i = 0; i<n; i++){
            a[i] = in.nextInt();
            sum += a[i];
            max = Math.max(max,  a[i]);
        }
        long ans = (sum / (n - 1)) + (sum % (n - 1) == 0 ? 0 : 1);
        out.println(Math.max(ans, max));
    }

    String input = "";
    String output = "";
    FastScanner in;
    PrintWriter out;

    void run() throws Exception {
        if (input.length() == 0) {
            in = new FastScanner(System.in);
        } else {
            in = new FastScanner(new File(input));
        }
        if (output.length() == 0) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(new File(output));
        }

        solve();

        out.close();

    }

    public static void main(String[] args) throws Exception {
        new C().run();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            bf = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File fr) throws FileNotFoundException {
            bf = new BufferedReader(new FileReader(fr));
        }

        public String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(bf.readLine());
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


import java.io.*;
import java.util.*;
public class x
{
    public static void main(String args[])throws IOException
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        double sum=0.0;
        int i;
        int max=-1;
        int x;
        for(i=0;i<n;i++)
        {
            x=in.nextInt();
            sum+=x;
            if(max<x)
            {
                max=x;
            }
        }
        long ans=(long)(Math.ceil(sum/(n-1)));
        System.out.println(Math.max(max,ans));
    }
}


import java.io.*;
import java.util.*;
public class x
{
    public static void main(String args[])throws IOException
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        double sum=0.0;
        int i;
        for(i=0;i<n;i++)
        {
            sum+=in.nextInt();
        }
        long ans=(long)(Math.ceil(sum/(n-1)));
        System.out.println(ans);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Mafia {
    public static void main(String[] Args) throws IOException{
        BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

        int num=Integer.parseInt(in.readLine());
        String[] val = in.readLine().split(" ");
        int[] play = new int[num];
        int min=0;
        int max=0;
        int times=0;
        for(int i=0; i< num;++i){
            play[i]=Integer.parseInt(val[i]);
            if(play[min]>play[i]){
                min=i;
            }
            if(play[max]<play[i]){
                max=i;
            }
        }
        while(play[max]>times){
            int del=play[max]-times;
            if(play[max]==play[min]){
                while(del>num){
                    times+=num;
                    del-=num-1;
                }
                if(del>0)++del;
                times+=del;
                break;
            }else{
                int t=play[max]-play[min];
                if (del<t)
                    t=del;
                times+=t;
                play[min]+=t;
            }
            for(int i=0; i< num;++i){
                if(play[min]>=play[i]){
                    min=i;
                }
                if(play[max]<=play[i]){
                    max=i;
                }
            }
        }
        System.out.print(times);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;

public class Mafia {
    public static void main(String[] Args) throws IOException{
        BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

        int num=Integer.parseInt(in.readLine());
        String[] val = in.readLine().split(" ");
        TreeSet<Integer> set = new TreeSet<Integer>();
        int max=0;
        int times=0;
        for(int i=0; i< num;++i){
            int play=Integer.parseInt(val[i]);
            set.add(play);
            if(max<play){
                max=play;
            }
        }
        while(max>times){
            int del=max-times;
            int play=set.first();
            if(max==play){
                while(del>num){
                    times+=num;
                    del-=num-1;
                }
                if(del>0)++del;
                times+=del;
                break;
            }else{
                int t=max-play;
                if (del<t)
                    t=del;
                times+=t;
            }
        }
        System.out.print(times);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.TreeSet;

public class Mafia {
    public static void main(String[] Args) throws IOException{
        BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

        int num=Integer.parseInt(in.readLine());
        String[] val = in.readLine().split(" ");
        PriorityQueue<Integer> set = new PriorityQueue<Integer>();
        int max=0;
        int times=0;
        for(int i=0; i< num;++i){
            int play=Integer.parseInt(val[i]);
            set.add(play);
            if(max<play){
                max=play;
            }
        }
        while(max>times){
            int del=max-times;
            int play=set.poll();
            if(max==play){
                while(del>num){
                    times+=num;
                    del-=num-1;
                }
                if(del>0)++del;
                times+=del;
                break;
            }else{
                int t=max-play;
                if (del<t)
                    t=del;
                times+=t;
            }
        }
        System.out.print(times);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.TreeSet;

public class Mafia {
    public static void main(String[] Args) throws IOException{
        BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

        int num=Integer.parseInt(in.readLine());
        String[] val = in.readLine().split(" ");
        PriorityQueue<Integer> set = new PriorityQueue<Integer>();
        int max=0;
        int times=0;
        for(int i=0; i< num;++i){
            int play=Integer.parseInt(val[i]);
            set.add(play);
            if(max<play){
                max=play;
            }
        }
        while(max>times){
            int del=max-times;
            int play=set.poll();
            if(max==play){
                while(del>=num){
                    times+=num;
                    del-=num-1;
                }
                if(del>0)++del;
                times+=del;
                break;
            }else{
                int t=max-play;
                if (del<t)
                    t=del;
                times+=t;
            }
        }
        System.out.print(times);
    }
}


import java.util.*;
import java.io.*;

public class CF348C{

	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;

	private static void soln(){
		int n = nextInt();
		int[] arr = nextIntArray(n);
		Arrays.sort(arr);
		if(arr[0] == arr[n-1])
			pw.println(arr[0]+1);
		else
			pw.println(Math.max(arr[n-1],arr[0] + arr[1]));
	}

	public static void main(String[] args){
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}

	// To Get Input
	// Some Buffer Methods

	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}

	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private static int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private static int nextInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static long nextLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}

}


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

int main() {
    int n;
    scanf("%d", &n);

    if (n < 3) {
        printf("%d\n", -1);
        return 0;
    }

    string s = "210";

    for (int i = 3; i < n; ++i)
        s += '0';

    cout << s << endl;
    return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);

    if (n < 3) {
        printf("%d\n", -1);
        return 0;
    }

    if (n == 3) {
        printf("210\n");
        return 0;
    }

    int mod = 1;
    for (int i = 0; i < n - 2; ++i) {
        mod = (mod * 10) % 21;
    }

    mod = 21 - mod;
    string s(n, '0');
    s[0] = '1';

    s[n - 2] = mod % 10 + '0';
    s[n - 3] = mod / 10 + '0';

    cout << s << endl;
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <string>
#include <vector>
#include <cctype>
#include <math.h>
#include <time.h>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

#define all(p) (p).begin(), (p).end()
#define fi first
#define se second

#define TASKNAME ""
//#define DEBUG

typedef long long ll;

const int N = 111111;
const ll INF = 1e9 * 1ll * 1e9;

int pow(int x, int n, int mod) {

    int ans = 1ll;

    while(n > 0) {
        if (n & 1) ans *= x;
        x *= x;
        n >>= 1;

        x %= mod;
        ans %= mod;
    }
    return ans;
}

int main() {

    int n;
    scanf("%d", &n);

    if (n < 3) {
        puts("-1");
        return 0;
    }

    if (n == 3) {
        puts("210");
        return 0;
    }

    printf("1");
    for (int i = 0; i < n - 4; ++i)
        printf("0");

    printf("%03d\n", 210 - pow(10, n - 1, 210));
    return 0;
}


#include "stdio.h"
#include <iostream>
using namespace std;

int main()
{
    int N;
    cin>>N;
    if(N==1 || N==2)
    {
        cout<<-1<<endl;
        return 0;
    }
        if(N==3)
        {
            cout<<210<<endl;
            return 0;
        }

        switch(N%6)
        {
        case 4:
            printf("1");
            for(int i=1;i<=N-3;++i)
                printf("0");
            cout<<5;
            cout<<0<<endl;
            break;
        case 5:
            printf("1");
            for(int i=1;i<=N-3;++i)
                printf("0");
            cout<<8;
            cout<<0<<endl;
            break;
        case 0:
            printf("1");
            for(int i=1;i<=N-4;++i)
                printf("0");
            printf("170\n");
            break;
        case 1:
            printf("1");
            for(int i=1;i<=N-3;++i)
                printf("0");
            cout<<20<<endl;
            break;
        case 2:
            printf("1");
            for(int i=1;i<=N-4;++i)
                printf("0");
            cout<<200<<endl;
            break;
        case 3:
            printf("1");
            for(int i=1;i<=N-4;++i)
                printf("0");
            printf("110\n");
            break;
        }
        return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <string>
#include <limits>
#include <string.h>
#include <math.h>
#include <stack>
#include <functional>
#include <sstream>
using namespace std;
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int main(){
  int n;
  int ar[6] = {1, 3, 2, 6, 4, 5};
  cin>>n;
  if(n == 1 || n == 2){
    cout<<-1<<endl;
    return 0;
  }
  if(n == 3){
    cout<<210<<endl;
    return 0;
  }
  for(int i = 0; i <= 10000000; i+=10){
    string cur = toString(i);
    int sum = 0;
    int prod = 0;
    for(int j = cur.size() - 1, cnt = 0; j >= 0; j--, cnt++){
      sum += cur[j] - '0';
      prod += (cur[j] - '0') * ar[cnt % 6];
    }
    sum += 1;
    prod += ar[(n-1) % 6];
    if(sum % 3 == 0 && prod % 7 == 0){
      string res; res = '1';
      for(int j = 0; j < n - cur.size() - 1; ++j){
	res += '0';
      }
      res += cur;
      cout<<res<<endl;
      return 0;
    }
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define sf              scanf
#define pf              printf
#define fs              first
#define se              second
#define pb              push_back
#define ins             insert
#define Lb              lower_bound
#define Up              upper_bound
#define INF             (1<<30)
#define mem(a,b)        memset(a, b, sizeof(a))
#define MAX             100010
#define MAXR            100010
#define MAXC            100010

typedef long long ll;

const double PI = 2.0 * acos(0.0);
const double eps = 1e-9;

template < class T > T Abs(T x) { return x > 0 ? x : -x; }
template < class T > string toString(T n) { ostringstream ost; ost << n; ost.flush() ; return ost.str(); }
template < class T > inline T gcd(T a,T b) { if(a < 0) return gcd(-a,b); if(b < 0)return gcd(a,-b); return (b == 0) ? a : gcd(b ,a % b); }
template < class T > inline T lcm(T a,T b) { if(a < 0) return lcm(-a,b); if(b < 0)return lcm(a,-b); return a * (b / gcd(a , b)); }
template < class T > inline T sqr(T n) { return n * n; }
template < class T > T power(T n, int p)
{
    if(!p) return 1;
    else
    {
        T sum = sqr( power( n ,  p >> 1) );
        if(p & 1) sum =  n;
        return sum;
    }
}

//ll bigmod(ll num , ll p , ll mod)
//{
//    ll sum = 1 , temp = num;
//    while(p)
//    {
//        if(p & 1) sum = (sum * temp) % mod;
//        temp = (temp * temp) % mod; p = p >> 1;
//    }
//    return sum;
//}

/// S , E  , N , W
//int one [] = {1 ,0,-1, 0};
//int two [] = {0 ,1, 0,-1};
///S , SE , E , NE , N , NW , W , SW
//int one [] = {1 ,1 ,0,-1,-1,-1, 0, 1};
//int two [] = {0 ,1 ,1 ,1, 0,-1,-1,-1};
///Knight Direction
//int one[]={2 ,1 ,-1,-2,-2,-1, 1, 2};
//int two[]={1 ,2 , 2, 1,-1,-2,-2,-1};

///============================================================================================////

string save [] = {"170","020","200","110","050","080"};

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(false);
    int n;
    cin >> n;
    if(n < 3) cout << -1 << endl;
    if(n == 3) cout << 210 << endl;
    cout << 1 ;
    for(int i = 1 ; i <= n - 4 ; ++i) cout << 0 ;
    cout << save[(n % 6)] << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define sf              scanf
#define pf              printf
#define fs              first
#define se              second
#define pb              push_back
#define ins             insert
#define Lb              lower_bound
#define Up              upper_bound
#define INF             (1<<30)
#define mem(a,b)        memset(a, b, sizeof(a))
#define MAX             100010
#define MAXR            100010
#define MAXC            100010

typedef long long ll;

const double PI = 2.0 * acos(0.0);
const double eps = 1e-9;

template < class T > T Abs(T x) { return x > 0 ? x : -x; }
template < class T > string toString(T n) { ostringstream ost; ost << n; ost.flush() ; return ost.str(); }
template < class T > inline T gcd(T a,T b) { if(a < 0) return gcd(-a,b); if(b < 0)return gcd(a,-b); return (b == 0) ? a : gcd(b ,a % b); }
template < class T > inline T lcm(T a,T b) { if(a < 0) return lcm(-a,b); if(b < 0)return lcm(a,-b); return a * (b / gcd(a , b)); }
template < class T > inline T sqr(T n) { return n * n; }
template < class T > T power(T n, int p)
{
    if(!p) return 1;
    else
    {
        T sum = sqr( power( n ,  p >> 1) );
        if(p & 1) sum =  n;
        return sum;
    }
}

//ll bigmod(ll num , ll p , ll mod)
//{
//    ll sum = 1 , temp = num;
//    while(p)
//    {
//        if(p & 1) sum = (sum * temp) % mod;
//        temp = (temp * temp) % mod; p = p >> 1;
//    }
//    return sum;
//}

/// S , E  , N , W
//int one [] = {1 ,0,-1, 0};
//int two [] = {0 ,1, 0,-1};
///S , SE , E , NE , N , NW , W , SW
//int one [] = {1 ,1 ,0,-1,-1,-1, 0, 1};
//int two [] = {0 ,1 ,1 ,1, 0,-1,-1,-1};
///Knight Direction
//int one[]={2 ,1 ,-1,-2,-2,-1, 1, 2};
//int two[]={1 ,2 , 2, 1,-1,-2,-2,-1};

///============================================================================================////

string save [] = {"170","020","200","110","050","080"};

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(false);
    int n;
    cin >> n;
    if(n < 3) cout << -1 << endl;
    else if(n == 3) cout << 210 << endl;
    else
    {
        cout << 1 ;
        for(int i = 1 ; i <= n - 4 ; ++i) cout << 0 ;
        cout << save[(n % 6)] << endl;
    }
    return 0;
}


   /* ******************************************************
   *  Md. Abdulla-Al-Sun
   *  Codeforces: sun.  , Topcoder : sun.
   *  Uva: sun. , SPOJ : sun_kuet  , LOJ : 5002 CodeChef: sun_kuet
   *  KUET, Bangladesh
   ****************************************************** */

#include <bits/stdc++.h>
#define scan(a) scanf("%d",&a)
#define rep0(i,n) for(int i = 0; i<n ;i++)
#define rep1(i,n) for(int i = 1; i<=n ;i++)
#define rep(i,a,b) for(int i = a; i<=b ;i++)
#define READ() freopen("input.txt","r",stdin);
int setbit(int N,int pos) { return N = N|(1<<pos); }
int resetbit(int N, int pos){ return N = N & ~(1<<pos) ;}
bool checkbit(int N,int pos) { return (bool) (N & 1<<pos) ;}
#define LL long long int
#define sz 100002
#define mod 1000000007
#define MAX 1000005
using namespace std;

bool prime[MAX];
void seive()
{
    for(int i=2;i<=MAX;i++)
        prime[i]=true;
    for(int i=4;i<=MAX;i+=2) prime[i]=false;
    for(int i=3;i<=sqrt(MAX);i+=2)
    {
        if(prime[i]==true)
        for(int j=i*i;j<MAX;j+=(2*i))
            prime[j]=false;
    }
}

int main()
{

    int n;
    cin >> n ;
    vector<int> v;

    if(n<=2)
    {
        cout << -1 << endl;
        return 0;
    }
    if(n==3)
    {
        cout << 210 << endl;
        return 0;
    }
    v.push_back(1);
    for(int i = 0 ; i< n-2 ;i++ )
    {
        v.push_back(0);
    }

    int cnt = 0, sum = 0 ;
    for(int i = 0 ; i < v.size() ; i++ )
    {
        sum = sum *10 + v[i];
        if(sum>=21)
            sum %=21;
    }
    sum = 21 -sum;
    for(int i = 0 ; i< n -3 ; i++ )
    {
        cout << v[i] ;
    }
    if(sum < 10)
        cout << 0 << sum << 0 << endl;
    else
        cout << sum << 0 << endl;

}


#include <iostream>
using namespace std;

string map[] = {"11", "5", "8", "17", "2", "20"};

int main () {
    int n, x;
    cin >> n;
    string ans = "1", a;
    if (n == 1 || n == 2) { cout << "-1" << endl; }
    else if (n == 3) { cout << "210" << endl; }
    else {
        x = (n - 3) % 6;
        for (int i = 0; i < n - map[x].size() - 2; i++) {
            ans.push_back('0');
        }
        for (int i = 0; i < map[x].size(); i++) ans.push_back(map[x][i]);
        ans.push_back('0');    cout << ans << endl;
    }
}


#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <bitset>
#include <cassert>
#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define x first
#define y second
#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)
#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))
using namespace std; typedef long double ld; template <class _T> inline _T sqr(const _T& x) {return x * x;} template <class _T> inline string tostr(const _T& a) {ostringstream os(""); os << a; return os.str();} const ld PI = 3.1415926535897932384626433832795L; const ld EPS = 5e-12; char TEMPORARY_CHAR; typedef long long ll; typedef unsigned long long ull; typedef set < int > SI; typedef vector < int > VI; typedef vector < vector < int > > VVI; typedef map < string, int > MSI; typedef pair < int, int > PII; const int INF = 1e9; typedef complex<ld> cbase; inline void fft (vector<cbase> &a, bool invert) {int n = (int)a.size(); for (int i = 1, j = 0; i < n; ++i) {int bit = n >> 1; for (; j >= bit; bit >>= 1) j -= bit; j += bit; if (i < j) swap(a[i], a[j]);} for (int len = 2; len <= n; len <<= 1) {ld ang = 2 * PI / len * (invert ? -1 : 1); cbase wlen(cos(ang), sin(ang)); for (int i = 0; i < n; i += len) {cbase w(1); for (int j=0; j < len / 2; ++j) {cbase u = a[i + j], v = a[i + j + len / 2] * w; a[i + j] = u + v; a[i + j + len / 2] = u - v; w *= wlen;}}} if (invert) for (int i = 0; i < n; ++i) a[i] /= n;} inline void input(int &a) {a = 0; while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){} char neg = 0; if (TEMPORARY_CHAR == '-') {neg = 1; TEMPORARY_CHAR = getchar();} while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0'; TEMPORARY_CHAR = getchar();} if (neg) a = -a;} inline void out(ll a) {if (!a) putchar('0'); if (a < 0) {putchar('-'); a = -a;} char s[20]; int i; for(i = 0; a; ++i) {s[i] = '0' + a % 10; a /= 10;} ford(j, i) putchar(s[j]);} inline int nxt() {in(ret); return ret;} struct lnum {vector <int> a; int base; lnum(int num = 0, int base = 1000000000):base(base) {if (!num) a.resize(1); while(num) {a.pb(num % base); num /= base;}} inline int len() const {return a.size();} lnum & operator=(const lnum &l) {if (this != &l) {a = l.a; base = l.base;} return *this;} inline friend lnum operator+(const lnum &l, const lnum &r) {lnum ret(0, l.base); int base = l.base; int ln = l.len(), rn = r.len(); int n = max(ln, rn); ret.a.resize(n); int o = 0; for(int i = 0; i < n; ++i) {int s = o; if (i < ln) s += l.a[i]; if (i < rn) s += r.a[i]; o = s >= base; if (o) s -= base; ret.a[i] = s;} if (o) ret.a.push_back(1); return ret;} inline friend lnum operator-(const lnum &l, const lnum &r) {lnum ret(0, l.base); int base = l.base; int n = l.len(); int rn = r.len(); ret.a.resize(n); int o = 0; for(int i = 0; i < n; ++i) {int s = l.a[i] - o; if (i < rn) s -= r.a[i]; o = s < 0; if (o) s += base; ret.a[i] = s;} if (ret.len() > 1 && !ret.a.back()) ret.a.pop_back(); return ret;} inline friend lnum operator*(const lnum &l, const lnum &r) {lnum ret(0, l.base); int base = l.base; if (l.len() * r.len() > 1000000) {vector<cbase> fa (l.a.begin(), l.a.end()), fb (r.a.begin(), r.a.end()); int n = 1; while (n < max (l.len(), r.len())) n <<= 1; n <<= 1; fa.resize (n), fb.resize (n); fft (fa, false), fft (fb, false); for (int i = 0; i < n; ++i) fa[i] *= fb[i]; fft (fa, true); ret.a.resize(n); for (int i = 0; i < n; ++i) ret.a[i] = int (fa[i].real() + 0.5); int carry = 0; for (int i=0; i < n; ++i) {ret.a[i] += carry; carry = ret.a[i] / base; ret.a[i] %= base;}} else {ret.a.resize(l.len() + r.len()); for (int i = 0; i < l.len(); ++i) for (int j = 0, carry = 0; j < r.len() || carry; ++j) {long long cur = ret.a[i + j] + (ll)l.a[i] * (j < r.len() ? r.a[j] : 0) + carry; ret.a[i + j] = cur % base; carry = cur / base;}} while (ret.len() > 1 && !ret.a.back()) ret.a.pop_back(); return ret;} inline friend lnum operator/(const lnum &l, const int &r) {lnum ret(0, l.base); ret.a.resize(l.len()); int carry = 0; for(int i = l.len() - 1; i >= 0; --i) {long long cur = l.a[i] + (ll)carry * l.base; ret.a[i] = cur / r; carry = cur % r;} while (ret.len() > 1 && ret.a.back() == 0) ret.a.pop_back(); return ret;}  inline friend bool operator<(const lnum &l, const lnum &r) {if (l.len() < r.len()) return true; if (l.len() > r.len()) return false; int n = l.len(); for(int i = n - 1; i >= 0; --i) {if (l.a[i] < r.a[i]) return true; if (l.a[i] > r.a[i]) return false;} return false;} inline friend bool operator>(const lnum &l, const lnum &r) {return r < l;} inline friend bool operator==(const lnum &l, const lnum &r) {if (l.len() != r.len()) return false; int n = l.len(); for(int i = n - 1; i; --i) {if (l.a[i] != r.a[i]) return false;} return true;} inline friend bool operator!=(const lnum &l, const lnum &r) {return !(l == r);} inline void print() {if (base == 1000000000) {printf("%d", a.back()); for(int i = a.size() - 2; i >=0; --i) printf("%09d", a[i]);} else {for(int i = a.size() - 1; i >= 0; --i) printf("%d", a[i]);}}};

inline int * arr(int n)
{
    int * ret = new int[n];
    forn(i, n)
        ret[i] = nxt();
    return ret;
}

int main()
{
    in(n);
    --n;
    lnum a;
    a.a.resize(n / 9 + 1);
    a.a[0] = 0;
    a.a.back() = 1;
    int k = n % 9;
    while(k--)
        a = a * 10;
    lnum rem = a - (a / 210) * 210;
    a = a + (210 - rem);
    a.print();
    return 0;
}


#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <bitset>
#include <cassert>
#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define x first
#define y second
#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)
#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))
using namespace std; typedef long double ld; template <class _T> inline _T sqr(const _T& x) {return x * x;} template <class _T> inline string tostr(const _T& a) {ostringstream os(""); os << a; return os.str();} const ld PI = 3.1415926535897932384626433832795L; const ld EPS = 5e-12; char TEMPORARY_CHAR; typedef long long ll; typedef unsigned long long ull; typedef set < int > SI; typedef vector < int > VI; typedef vector < vector < int > > VVI; typedef map < string, int > MSI; typedef pair < int, int > PII; const int INF = 1e9; typedef complex<ld> cbase; inline void fft (vector<cbase> &a, bool invert) {int n = (int)a.size(); for (int i = 1, j = 0; i < n; ++i) {int bit = n >> 1; for (; j >= bit; bit >>= 1) j -= bit; j += bit; if (i < j) swap(a[i], a[j]);} for (int len = 2; len <= n; len <<= 1) {ld ang = 2 * PI / len * (invert ? -1 : 1); cbase wlen(cos(ang), sin(ang)); for (int i = 0; i < n; i += len) {cbase w(1); for (int j=0; j < len / 2; ++j) {cbase u = a[i + j], v = a[i + j + len / 2] * w; a[i + j] = u + v; a[i + j + len / 2] = u - v; w *= wlen;}}} if (invert) for (int i = 0; i < n; ++i) a[i] /= n;} inline void input(int &a) {a = 0; while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){} char neg = 0; if (TEMPORARY_CHAR == '-') {neg = 1; TEMPORARY_CHAR = getchar();} while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0'; TEMPORARY_CHAR = getchar();} if (neg) a = -a;} inline void out(ll a) {if (!a) putchar('0'); if (a < 0) {putchar('-'); a = -a;} char s[20]; int i; for(i = 0; a; ++i) {s[i] = '0' + a % 10; a /= 10;} ford(j, i) putchar(s[j]);} inline int nxt() {in(ret); return ret;} struct lnum {vector <int> a; int base; lnum(int num = 0, int base = 1000000000):base(base) {if (!num) a.resize(1); while(num) {a.pb(num % base); num /= base;}} inline int len() const {return a.size();} lnum & operator=(const lnum &l) {if (this != &l) {a = l.a; base = l.base;} return *this;} inline friend lnum operator+(const lnum &l, const lnum &r) {lnum ret(0, l.base); int base = l.base; int ln = l.len(), rn = r.len(); int n = max(ln, rn); ret.a.resize(n); int o = 0; for(int i = 0; i < n; ++i) {int s = o; if (i < ln) s += l.a[i]; if (i < rn) s += r.a[i]; o = s >= base; if (o) s -= base; ret.a[i] = s;} if (o) ret.a.push_back(1); return ret;} inline friend lnum operator-(const lnum &l, const lnum &r) {lnum ret(0, l.base); int base = l.base; int n = l.len(); int rn = r.len(); ret.a.resize(n); int o = 0; for(int i = 0; i < n; ++i) {int s = l.a[i] - o; if (i < rn) s -= r.a[i]; o = s < 0; if (o) s += base; ret.a[i] = s;} if (ret.len() > 1 && !ret.a.back()) ret.a.pop_back(); return ret;} inline friend lnum operator*(const lnum &l, const lnum &r) {lnum ret(0, l.base); int base = l.base; if (l.len() * r.len() > 1000000) {vector<cbase> fa (l.a.begin(), l.a.end()), fb (r.a.begin(), r.a.end()); int n = 1; while (n < max (l.len(), r.len())) n <<= 1; n <<= 1; fa.resize (n), fb.resize (n); fft (fa, false), fft (fb, false); for (int i = 0; i < n; ++i) fa[i] *= fb[i]; fft (fa, true); ret.a.resize(n); for (int i = 0; i < n; ++i) ret.a[i] = int (fa[i].real() + 0.5); int carry = 0; for (int i=0; i < n; ++i) {ret.a[i] += carry; carry = ret.a[i] / base; ret.a[i] %= base;}} else {ret.a.resize(l.len() + r.len()); for (int i = 0; i < l.len(); ++i) for (int j = 0, carry = 0; j < r.len() || carry; ++j) {long long cur = ret.a[i + j] + (ll)l.a[i] * (j < r.len() ? r.a[j] : 0) + carry; ret.a[i + j] = cur % base; carry = cur / base;}} while (ret.len() > 1 && !ret.a.back()) ret.a.pop_back(); return ret;} inline friend lnum operator/(const lnum &l, const int &r) {lnum ret(0, l.base); ret.a.resize(l.len()); int carry = 0; for(int i = l.len() - 1; i >= 0; --i) {long long cur = l.a[i] + (ll)carry * l.base; ret.a[i] = cur / r; carry = cur % r;} while (ret.len() > 1 && ret.a.back() == 0) ret.a.pop_back(); return ret;}  inline friend bool operator<(const lnum &l, const lnum &r) {if (l.len() < r.len()) return true; if (l.len() > r.len()) return false; int n = l.len(); for(int i = n - 1; i >= 0; --i) {if (l.a[i] < r.a[i]) return true; if (l.a[i] > r.a[i]) return false;} return false;} inline friend bool operator>(const lnum &l, const lnum &r) {return r < l;} inline friend bool operator==(const lnum &l, const lnum &r) {if (l.len() != r.len()) return false; int n = l.len(); for(int i = n - 1; i; --i) {if (l.a[i] != r.a[i]) return false;} return true;} inline friend bool operator!=(const lnum &l, const lnum &r) {return !(l == r);} inline void print() {if (base == 1000000000) {printf("%d", a.back()); for(int i = a.size() - 2; i >=0; --i) printf("%09d", a[i]);} else {for(int i = a.size() - 1; i >= 0; --i) printf("%d", a[i]);}}};

inline int * arr(int n)
{
    int * ret = new int[n];
    forn(i, n)
        ret[i] = nxt();
    return ret;
}

int main()
{
    in(n);
    if (n <= 2)
    {
        puts("-1");
        return 0;
    }
    --n;

    lnum a;
    a.a.resize(n / 9 + 1);
    a.a[0] = 0;
    a.a.back() = 1;
    int k = n % 9;
    while(k--)
        a = a * 10;
    lnum rem = a - (a / 210) * 210;
    a = a + (210 - rem);
    a.print();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int BigMod(long long B,long long P,long long M)
{
    long long R=1;
    while(P>0)
    {
        if(P%2==1)
        {
            R=(R*B)%M;
        }
        P/=2;
        B=(B*B)%M;
    }
    return R;
}
int main(){
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int n;
    cin>>n;
    if(n<3){
        cout<<"-1\n";
        return 0;
    }
    if(n==3){
        cout<<210<<endl;
        return 0;
    }
    string s="1";
    for(int i=1;i<n;i++){
        s+="0";
    }
    int x=BigMod(10,n-1,210);
    x=210-x;
    string y="";
    while(x){
        y+=char('0'+x%10);
        x/=10;
    }
    for(int i=n-1,j=0;j<y.size() && i>=0;i--,j++){
        s[i]=y[j];
    }
    cout<<s<<endl;
    return 0;
}


#include <list>
#include <fstream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <map>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
//#include "sqrt.cpp"
//#include "tree.cpp"
//#include "funcs.cpp"

#define all(x)          (x).begin(), (x).end()
#define max(x, y)       ((x)>(y))?(x):(y)
#define forn(N)         for(int i = 0; i<N; i++)
#define fornj(N)         for(int j = 0; j<N; j++)
#define PI 3.1415926535897932384626433
using namespace std;

//#define ONLINE_JUDGE

int m[6] = {1, 3, 2, 6, 4, 5};

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    #endif

    int N;
    cin>>N;

    if (N==1 || N==2)
    {
        cout<<-1;
        return 0;
    }
    if (N==3)
    {
        cout<<210;
        return 0;
    }

    N--;

    int i=0;

    while ((m[N%6]+(2+3*i)*10)%7!=0)
    {
        i++;
    }

    cout<<1;
    forn(N-2-1)
        cout<<0;

    if (i==0 || i==1 || i==2)
        cout<<0;

    cout<<2+3*i;

    cout<<0;

    //printf("\n\ntime-%.3lf", clock()*1e-3);
    return 0;
}


#include <list>
#include <fstream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <map>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
//#include "sqrt.cpp"
//#include "tree.cpp"
//#include "funcs.cpp"

#define all(x)          (x).begin(), (x).end()
#define max(x, y)       ((x)>(y))?(x):(y)
#define forn(N)         for(int i = 0; i<N; i++)
#define fornj(N)         for(int j = 0; j<N; j++)
#define PI 3.1415926535897932384626433
using namespace std;

//#define ONLINE_JUDGE

int m[6] = {1, 3, 2, 6, 4, 5};

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    #endif

    int N;
    cin>>N;

    if (N==1 || N==2)
    {
        cout<<-1;
        return 0;
    }
    if (N==3)
    {
        cout<<210;
        return 0;
    }

    N--;

    int i=0;

    while ((m[N%6]+(8+3*i)*10)%7!=0)
    {
        i++;
    }

    cout<<1;
    forn(N-2-1)
        cout<<0;

    if (i==0)
        cout<<0;

    cout<<8+3*i;

    cout<<0;

    //printf("\n\ntime-%.3lf", clock()*1e-3);
    return 0;
}


#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

void solve(istream &in, ostream &out)
{
	int n;
	in >> n;

	if (n <= 2) {
		out << -1;
		return;
	}

	if (n == 3) {
		out << 210;
		return;
	}

	switch (n % 6) {
		case 4:
			out << 1;
			for (int i = 0; i < n - 3; ++i)
				out << 0;
			out << 50;
			return;
		case 5:
			out << 1;
			for (int i = 0; i < n - 3; ++i)
				out << 0;
			out << 80;
			return;
		case 0:
			out << 1;
			for (int i = 0; i < n - 4; ++i)
				out << 0;
			out << 170;
			return;
		case 1:
			out << 1;
			for (int i = 0; i < n - 3; ++i)
				out << 0;
			out << 20;
			return;
		case 2:
			out << 1;
			for (int i = 0; i < n - 4; ++i)
				out << 0;
			out << 200;
			return;
		case 3:
			out << 1;
			for (int i = 0; i < n - 4; ++i)
				out << 0;
			out << 110;
			return;
	}
}

int main() {
	solve(cin, cout);
	return 0;
}


#include <iostream>
using namespace std;

#define THREE 0
#define SEVEN 1

int n, mod[2];

int main() {
	cin >> n;
	if(n < 3)
		cout << -1 << endl;
  	if(n == 3)
		cout << 210 << endl;
	if(n <= 3) return 0;

	mod[THREE] = mod[SEVEN] = 1;

	for(int i = 0; i < n-1; i++) {
		mod[THREE] *= 10;
		mod[THREE] %= 3;
		mod[SEVEN] *= 10;
		mod[SEVEN] %= 7;
	}

	int ans = -1;
	for(int i = 0; i < 1000; i++) {
		int m3 = (mod[THREE]+i)%3;
		int m7 = (mod[SEVEN]+i)%7;
		if(i%2 || m3 || i%5 || m7) continue;
		ans = i;
		break;
	}

	if(ans != -1) {
		cout << 1;
		for(int i = 0; i < n-3; i++)
			cout << 0;
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}

}


#include <iostream>
#include <sstream>
using namespace std;

#define THREE 0
#define SEVEN 1

int n, mod[2];

string to_string(int a) {
	stringstream ss;
	ss << a;
	return ss.str();
}

int main() {
	cin >> n;
	if(n < 3)
		cout << -1 << endl;
  	if(n == 3)
		cout << 210 << endl;
	if(n <= 3) return 0;

	mod[THREE] = mod[SEVEN] = 1;

	for(int i = 0; i < n-1; i++) {
		mod[THREE] *= 10;
		mod[THREE] %= 3;
		mod[SEVEN] *= 10;
		mod[SEVEN] %= 7;
	}

	int ans = -1;
	for(int i = 0; i < 1000; i++) {
		int m3 = (mod[THREE]+i)%3;
		int m7 = (mod[SEVEN]+i)%7;
		if(i%2 || m3 || i%5 || m7) continue;
		ans = i;
		break;
	}

	if(ans != -1) {
		cout << 1;
		int len = to_string(ans).length();
		for(int i = 0; i < n-len-1; i++)
			cout << 0;
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}

}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<cstdlib>
#include<cmath>
#define PI 2*asin(1.0)
#define LL __int64
#define pb push_back
#define clr(a,b) memset(a,b,sizeof(a))
const int  MOD = 1e9 + 7;
const int N = 2e2 + 15;
const int INF = (1 << 30) - 1;
const int letter = 130;
using namespace std;
int n;
string aim[6];
int main() {
    aim[0] = "05";
    aim[1] = "08";
    aim[2] = "17";
    aim[3] = "02";
    aim[4] = "20";
    aim[5] = "11";
    while(scanf("%d", &n) != EOF) {
        if(n < 3) {
            puts("-1");
            continue;
        }
        if(n == 3) {
            puts("210");
            continue;
        }
        int len = n - 4;
        printf("1");
        for(int i = 1;i <= n-4;i++)
            printf("0");
        cout<<aim[len%6];
        cout << "0";
        cout << endl;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	char Soln[5];
	int i,n,rem,count,hit;
	scanf("%d",&n);
	if (n<=2)
	{
		printf("-1");}
	else if (n==3)
	{
		printf("210");}
	else
	{
		printf("1");
		for (i=2;i<=(n-3);i++)
		{
			printf("0");}
		count=4;
		hit=0;
		while(count<=n)
		{
			if (hit==0)
			{
				rem=50;}
			else if (hit==1)
			{
				rem=(rem + 30) % 210;}
			else if (hit==2)
			{
				rem=(rem + 90) % 210;}
			else if (hit==3)
			{
				rem=(rem + 60) % 210;}
			else if (hit==4)
			{
				rem=(rem + 180) % 210;}
			else if (hit==5)
			{
				rem=(rem + 120) % 210;}
			hit++;
			count++;
			if (hit==6)
			{
				hit=0;}
		}
	}
	itoa(rem, Soln, 10);
	if (strlen(Soln)<3)
	{
		printf("0");}
	printf("%s",Soln);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	char Soln[5];
	int i,n,rem,count,hit;
	scanf("%d",&n);
	if (n<=2)
	{
		printf("-1");}
	else if (n==3)
	{
		printf("210");}
	else
	{
		printf("1");
		for (i=2;i<=(n-3);i++)
		{
			printf("0");}
		count=4;
		hit=0;
		while(count<=n)
		{
			if (hit==0)
			{
				rem=50;}
			else if (hit==1)
			{
				rem=(rem + 30) % 210;}
			else if (hit==2)
			{
				rem=(rem + 90) % 210;}
			else if (hit==3)
			{
				rem=(rem + 60) % 210;}
			else if (hit==4)
			{
				rem=(rem + 180) % 210;}
			else if (hit==5)
			{
				rem=(rem + 120) % 210;}
			hit++;
			count++;
			if (hit==6)
			{
				hit=0;}
		}
		itoa(rem, Soln, 10);
		if (strlen(Soln)<3)
		{
			printf("0");}
		printf("%s",Soln);
	}
	return 0;
}


#include <stdio.h>
int main(){
  int rem[6]={40,190,10,100,160,130};
  int n,sum;
  scanf("%d",&n);
  if(n<3)
    printf("-1\n");
  else if(n == 3){
    printf("210\n");
  }else {
    sum = 210-rem[n%6];
 		printf("1");
    int digLenght = (sum/100 == 0)?2:3, i=0;
    for(i=1;i<n-digLenght;i++)
      printf("0");
    printf("%d\n",sum);
  }
  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define modulo 210

int main()
{
	int num=0,n=0;
	scanf("%d",&num);
	if(num==1 || num==2)
		printf("-1\n");
	else if(num==3)
		printf("210\n");
	else
	{
		n=num;
		int a=1;
		while(n!=1)
		{
			a*=10;
			a%=modulo;
			n--;
		}
		a=modulo-a;
		char s[num+1];
		s[0]='1';
		int i=0;
		for(i=1;i<num;i++)
			s[i]='0';
		int XX=num;
		while(a!=0)
		{
			char x=a%10+'0';
			a/=10;
			s[--XX]=x;
		}
		s[num]='\0';
		printf("%s\n",s);
	}
	return 0;
}


#include<stdio.h>
int arr[4]={2,3,5,7};
int recursion(int n,int a)
{
    int i,count=0,prev_m,m=a;
    while(m)
    {
        count++;
        m=m/10;
    }
    if(count==n)
    return a;
    if(count>n)
    return -1;
    for(i=0;i<4;i++)
    {
        m=recursion(n,arr[i]*a);
        if(i==0)
        prev_m=m;
        else
        {
            if(prev_m>m)
            prev_m=m;
        }
    }
    return prev_m;
}
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",recursion(n,120));
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f -*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAGIC 210
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;

int main()
{
   int i,j,n;
   scanf("%d",&n);
   if(n<=2){
      printf("-1\n");
      return 0;
   }
   if(n==3){
      printf("210\n");
      return 0;
   }
   printf("1");
   int rem=100%MAGIC;
   for(i=4;i<=n;++i){
      printf("0");
      rem=(rem*10)%MAGIC;
   }
   //printf("rem is %d\n",rem);
   printf("%d\n",MAGIC-rem);
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f -*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAGIC 210
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;

int main()
{
   int i,j,n;
   scanf("%d",&n);
   if(n<=2){
      printf("-1\n");
      return 0;
   }
   if(n==3){
      printf("210\n");
      return 0;
   }
   printf("1");
   int rem=1000%MAGIC;
   for(i=4;i<n;++i){
      printf("0");
      rem=(rem*10)%MAGIC;
   }

   printf("%03d\n",MAGIC-rem);
   if(rem>=210) printf("error\n");
   return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n<=2)
		printf("-1\n");
	else
	{
		int p=pow(10,n-1);
//		printf("%d\n",p);
		int u=p/210;
		if(p%210==0)
			printf("%d\n",p);
		else
			printf("%d\n",(u+1)*210);
		return 0;
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void cal(unsigned int n)
{
    int i,k;
    k = 1000%210;
    for(i = 4 ; i < n ; i++)
        k = (k*10)%210;

    k = 210 - k;
    printf("1");
    if(k == 0)
    {
        for(i = 1 ; i < n ; i++)
            printf("0");
    }
    else if(k < 100)
    {
        for(i = 3 ; i < n ; i++)
            printf("0");
        printf("%d",k);
    }
    else
    {
        for(i = 4 ; i < n ; i++)
            printf("0");
        printf("%d",k);
    }
    printf("\n");
}

int main()
{
    unsigned int n;
    scanf("%d",&n);

    if(n < 3)
        printf("-1\n");
    else if(n == 3)
        printf("210\n");
    else
       cal(n);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int N, A, B, i;

int main(){
    while(~scanf("%d", &N)){
        if (N<3){
            printf("-1\n");
            continue;
        }
        if (N==3){
            printf("210\n");
            continue;
        }
        putchar(49);
        for (i=4; i<N; i++) putchar(48);

        A = N%6;

        if (A==0) B = 17;
        if (A==1) B = 2;
        if (A==2) B = 20;
        if (A==3) B = 11;
        if (A==4) B = 5;
        if (A==5) B = 8;

        printf("%02d", B);
        putchar(48);
        putchar(10);
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n<=2){
		printf("-1\n");
		return 0;
	}
	if(n==3)
		printf("210\n");
	else if(n==4)
		printf("1050\n");
	else{
		printf("1");
		n-=1;
		int num_z = n-4;
		for(;n>3;n--){
			printf("0");
		}
		int rem[6] = {3,2,6,4,5,1};
		int num = rem[num_z%6]*100;
		int dig_sum = 1;
		while(num%7!=0 || dig_sum%3!=0){
			num+=1;
			dig_sum=1;
			int num2 = num;
			while(num2>10){
				dig_sum+=(num2%10);
				num2/=10;
			}
		}
		char out[2];
		int i=1;
		while(num>=10){
			out[i]=num%10+48;
			i--;
			num/=10;
		}
		printf("%c%c0\n",out[0],out[1]);

	}
	return 0;
}


#include <stdio.h>

int tensdigit(int num)
{
	num=num/10;
	return num%10;
}

int hundredsdigit(int num)
{
	return num/100;
}

int main()
{
	int n,i;
	scanf("%d",&n);
	if(n<3)
	{
		printf("-1\n");
		return 0;
	}
	if(n==3)
	{
		printf("210\n");
		return 0;
	}
	int numberarray[100004]={0};
	numberarray[0]=1;
	numberarray[n-1]=0;
	int x;
	if(n%6==0)
	{
		x=-100;
	}
	if(n%6==1)
	{
		x=1;
	}
	if(n%6==2)
	{
		x=10;
	}
	if(n%6==3)
	{
		x=100;
	}
	if(n%6==4)
	{
		x=-1;
	}
	if(n%6==5)
	{
		x=-10;
	}
	int decidingNumber,temp;
	int tens,hundreds;
	for(decidingNumber=0;decidingNumber<1000;decidingNumber+=10)
	{
		temp=decidingNumber;
		temp=temp+x;
		if(temp%7!=0)
			continue;
		tens=tensdigit(decidingNumber);
		hundreds=hundredsdigit(decidingNumber);
		if((tens+hundreds+1)%3==0)
			break;
	}
	numberarray[n-2]=tens;
	numberarray[n-3]=hundreds;
	for(i=0;i<n;i++)
		printf("%d",numberarray[i]);
	printf("\n");
	return 0;
}


#include <stdio.h>

int main()
{
	int n,i;
	scanf("%d",&n);
	if(n<3)
	{
		printf("-1\n");
		return 0;
	}
	int number=210;
	if(n==3)
	{
		printf("210\n");
		return 0;
	}
	int multiply=2;
	int x=1;
	for(i=1;i<=n-1;i++)
	{
		x*=10;
	}
	int numberr=210;
	while(numberr<x)
	{
		numberr=number*multiply;
		multiply++;
	}
	printf("%d\n",numberr);
	return 0;
}


#include<stdio.h>

int find_mod(int n)
{
    int a = 1;
    n -= 2;
    while(n--)
        a = ((a % 21)*10)%21;
    return a;
}

int main()
{
    int n;
    scanf("%d",&n);
    if(n < 3)
        printf("-1");
    else if(n == 3)
        printf("210");
    else
    {
        int x = find_mod(n);
        int to_add = 21 - x;
        printf("1");
        for(int i = 0; i < n-4; i++)
        printf("0");
        if(to_add / 10)
            printf("%d",to_add);
        else printf("0%d",to_add);
        printf("0");
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<memory.h>
#include<assert.h>
#include<ctype.h>

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(k) (((k)>0)?(k):(-(k)))
#define mod(a,b) (((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)))
#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define inf (1e9)
#define linf (1e18)
#define pi 3.14159265358979323846

typedef long long ll;

void fileio_in_out()
{
     freopen(".in","r",stdin);
     freopen(".out","w",stdout);
}

void fileio_txt()
{
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
}

//==================================================

int n,ans,t;
int i,j,k,l;

int f(int k)
{
    int i,t=1;

    for(i=1;i<=k;i++)
      t=(t*10)%210;
    return t;
}

int main()
{
    //fileio_in_out();
    //fileio_txt();

    scanf("%d",&n);
    if(n<=3)
      printf("%d\n",(n==3)?210:-1);
      else
        {
          printf("1");
          for(i=1;i<n-3;i++)
            printf("0");
          t=210-f(n-1);
          if(t<100)
            printf("0");
          printf("%d\n",t);
        }

    //system("pause");
    return 0;
}


#include <stdio.h>
#include <conio.h>

void indayso(int n,int x,int kc)
{
    int i = 2;
    printf("1");
    for (i = 2; i <= n - kc; i++)
        printf("0");
    printf("%d", x);

}

int main()
{
    int n, i;
    scanf("%d", &n);
    if (n < 3) printf("-1");
    else if (n == 3) printf("210");
    else
    {
        i = n % 6;
        if (i == 4) indayso(n,50,2);
        else if (i == 5) indayso(n,80,2);
        else if (i == 0) indayso(n,170,3);
        else if (i == 1) indayso(n,20,2);
        else if (i == 2) indayso(n,200,3);
        else indayso(n,110,3);
    }

    return 0;
}


#include<stdio.h>

int main()
{
    long long n,num=1,c=0,div;
    scanf("%I64d",&n);
    while(c<n-1)
    {
              num*=10;
              c++;
    }
    if(num<210)
             printf("-1");
    else
    {
        div=num/210;
        if(num-div*210!=0)
        printf("%I64d",210*(div+1));
        else
        printf("%I64d",num);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main () {
  int i, n;
  scanf("%d", &n);

  if (n <= 3)
    printf ("%d\n", n == 3 ? 210 : -1);
  else {
    int md = 1;
    for (i = 0; i < n - 1; ++i)
      md = md*10 % 210;
    printf ("1%.*d%.*d\n", n - 4, 0, 3, 210 - mod);
  }
  exit (EXIT_SUCCESS);
}


#include <stdio.h>
#include <stdlib.h>

int main () {
  int i, n;
  scanf("%d", &n);

  if (n <= 3)
    printf ("%d\n", n == 3 ? 210 : -1);
  else {
    int md = 1;
    for (i = 0; i < n - 1; ++i)
      md = md*10 % 210;
    printf ("1%.*d%.*d\n", n - 4, 0, 3, 210 - md);
  }
  exit (EXIT_SUCCESS);
}


#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
  scanf ("%d", &n);

  if (n < 3)
    printf ("-1\n");
  else if (n == 3)
    printf ("210\n");
  else
    printf ("1%.*d%.*d", n - 4, 0, 3, suf[n % P]);

  exit (EXIT_SUCCESS);
}


#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
  scanf ("%d", &n);

  if (n < 3)
    printf ("-1\n");
  else if (n == 3)
    printf ("210\n");
  else {
    int i;
    printf ("1");
    for (i = 0; i < n-4; ++i)
      printf ("0");
    printf ("%.3d\n", suf[n % P]);
  }
  exit (EXIT_SUCCESS);
}


#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
  scanf ("%d", &n);

  if (n < 3)
    printf ("-1\n");
  else if (n == 3)
    printf ("210\n");
  else {
    int i;
    printf ("1");
    for (i = 0; i < n-4; ++i)
      printf ("0");
    printf ("%.*d\n", 3, suf[n % P]);
  }
  exit (EXIT_SUCCESS);
}


#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
  scanf ("%d", &n);

  if (n < 3)
    printf ("-1\n");
  else if (n == 3)
    printf ("210\n");
  else {
    int i;
    printf ("1");
    for (i = 0; i < n-4; ++i)
      printf ("0");
    printf ("%3d\n", suf[n % P]);
  }
  exit (EXIT_SUCCESS);
}


#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
  scanf ("%d", &n);

  if (n < 3)
    printf ("-1\n");
  else if (n == 3)
    printf ("210\n");
  else
    printf ("1%.*d%.*d\n", n - 4, 0, 3, suf[n % P]);

  exit (EXIT_SUCCESS);
}