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

int main(){
  int N;
  int total = 0;
  cin >> N;
  
  for(int i = 1;total < N;i++){
    total += i;
    if(total >= N){
      cout << i << endl;
      break;
    }
  }
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()



int main(){
    int n;
    cin>>n;
    vector<int> t(n);
    int sum=0;
    rep(i,n){
        cin>>t[i];
        sum+=t[i];
    }

    if(n==1){
        cout<<t[0]<<endl;
        return 0;
    }

    int ans;
    if(sum%2==0) ans=sum/2;
    else ans=sum/2+1; 
    bool dp[n+10][sum+10];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = true;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j <= sum+10; ++j) {
        dp[i+1][j] |= dp[i][j];
        if (j >= t[i]) dp[i+1][j] |= dp[i][j-t[i]];
      }
    }
    while(1){      
        if(dp[n][ans]){
            cout<<ans<<endl;
            return 0;
        }
        ans++;
    }
}

