#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<size_t> T(N);
  size_t S = 0;
  for (auto& ti: T) {
    scanf("%zu", &ti);
    S += ti;
  }

  size_t M = 2500;
  std::vector<std::vector<bool>> dp0(M+1, std::vector<bool>(M+1));
  auto dp1 = dp0;
  dp0[0][0] = true;
  for (size_t i = 0; i < N; ++i) {
    for (size_t s = 0; s <= M; ++s) {
      for (size_t t = 0; t <= M; ++t) {
        if (!dp0[s][t]) continue;
        if (t + T[i] <= M)
          dp1[s][t+T[i]] = true;
        if (s + T[i] <= M)
          dp1[s+T[i]][t] = true;
      }
    }
    dp0 = dp1;
  }

  size_t res = M+M;
  for (size_t i = 0; i <= M; ++i)
    for (size_t j = 0; j <= M; ++j) {
      if (!dp0[i][j]) continue;
      size_t k = S - (i+j);
      res = std::min(res, std::max({i, j, k}));
    }

  printf("%zu\n", res);
}

