#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9;

int main(){
  int N;
  cin >> N;
  vector<int> T(N);
  int s = 0;
  for(int i = 0; i < N; ++i) cin >> T[i], s += T[i];
  vector<vector<int>> dp(s+1,vector<int>(s+1,INF));
  dp[0][0] = 0;
  for(int i = 0; i < N; ++i){
    vector<vector<int>> dp_(s+1,vector<int>(s+1,INF));
    int t = T[i];
    for(int j = 0; j <= s; ++j){
      for(int k = 0; k <= s; ++k){
        if(dp[j][k] >= INF) continue;
        if(j + t <= s) dp_[j+t][k] = dp[j][k];
        if(k + t <= s) dp_[j][k+t] = dp[j][k];
        dp_[j][k] = dp[j][k] + t;
      }
    }
    dp = dp_;
  }
  int ans = 1e9;
  for(int i = 0; i <= s; ++i)
    for(int j = 0; j <= s; ++j)
      ans = min(ans,max({i,j,dp[i][j]}));
  cout << ans << endl;
}

