/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.cpp
* Author: alex
*
* Created on October 6, 2016, 9:19 PM
*/
#include <cstdlib>
using namespace std;
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
/*
*
*/
int etsi (long x,vector< pair<long,long> > v, long o , int y[],long d){
long n=v.size();
long k=0;
/* if (y[x]==1){
return 1;
}*/
for (long b = n/2; b >= 1; b /= 2) {
while(k+b<n&&v.at(k+b).first<x){
k+=b;
}
}
if(k<v.size()-1&&v.at(k+1).first==x){
k++;
}
while(o!=-1&&v.at(k)>=v.at(o)){
k--;
if(k<0){
return 0;
}
}
if(k<0){
return 0;
}
if(v.at(k).first>x){
return 0;
}
if(x-v.at(k).first*v.at(k).second<v.at(k).first) {
return 1;
}
for (int i = v.at(k).second; i > 0; i--) {
int pa= etsi(x-v.at(k).first*i,v,k,y,0);
return 1;
}
return 0;
}
int main(int argc, char** argv) {
long n;
cin >> n;
long l[n];
long a;
long j=0;
vector< pair<long,long> > v;
for (int i = 0; i < n; i++) {
cin >> a;
l[i]=a;
}
sort(l, l+n);
a=l[0];
long r=1;
long f;
for (int i = 1; i < n; i++) {
f=l[i];
if(f==a){
r++;
a=f;
}else{
pair <int,int> p=make_pair(a,r);
v.push_back(p);
j++;
a=f;
r=1;
}
}
pair <int,int> p=make_pair(a,r);
v.push_back(p);
int i=1;
while(etsi(i,v,-1,y)){
i++;
}
cout << i;
return 0;
}