#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>


int main() {
	int n; std::cin >> n;
	std::vector<int> papers(n); for (auto& t : papers) std::cin >> t;
	const auto sum = std::accumulate(papers.begin(), papers.end(), 0);
	std::vector<std::vector<std::vector<bool>>> memo(n + 1, std::vector<std::vector<bool>>((sum + 2) / 3 + 51, std::vector<bool>((sum + 2) / 3 + 1, false)));
	memo[0][0][0] = true;
	for (auto i = 0; i < papers.size(); ++i) {
		for (auto j = 0; j < memo[i].size(); ++j) {
			for (auto k = 0; k < memo[i][j].size(); ++k) {
				bool res = memo[i][j][k];
				if (j >= papers[i]) {
					res = res || memo[i][j - papers[i]][k];
				}
				if (k >= papers[i]) {
					res = res || memo[i][j][k - papers[i]];
				}
				memo[i + 1][j][k] = res;
			}
		}
	}
	for (auto i = sum / 3; i < memo.back().size(); ++i) {
		for (auto j = std::max(0, sum - i * 2); j < memo.back()[i].size() && j <= sum - i - j; ++j) {
			if (memo.back()[i][j]) {
				std::cout << i << '\n';
				return 0;
			}
		}
	}
}

