#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
//#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.push_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}
template<typename T_vector>
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}  
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fio;
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    while(t--)
    {
        string s;
        cin >> s;
        ll n = (ll)s.size();
        bool ok = true;
        for(int i = 0; i < n; i++)
        {
            if(i % 2 == 0)
            ok &= (s[i] >= 'a' && s[i] <= 'z');
            else
            ok &= (s[i] >= 'A' && s[i] <= 'Z');
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';    
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
int mod=1e9+7;
int gcd(int x,int y)
{
    if(y==0)
    {
        return x;
    }
    return gcd(y,x%y);
}
int power(int a,int n)
{
    int res=1;
    while(n)
    {
        if(n%2)
        {
            res=(res*a)%mod;
        }
        n=n/2;
        a=(a*a)%mod;
    }
    return res;
}
void solve()
{
    int i,j,n,total=0,ans=1e8;
    cin>>n;
    vector<int> arr;
    arr.assign(n,0);
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        total=total+arr[i];
    }
    int dp[n+1][total+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=total;j++)
        {
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=total;j++)
        {
            if(j<arr[i-1])
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=dp[i-1][j]+dp[i-1][j-arr[i-1]];
            }
        }
    }
    for(j=1;j<total;j++)
    {
        if(dp[n][j])
        {
            ans=min(ans,max(j,total-j));
        }
    }
    if(n==1)
    {
        cout<<arr[0];
        return;
    }
    cout<<ans;
}
int32_t main()
{
    int t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}
