const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
const n = Number(await readline());
const maxSize = 1474560 / 512;
let sizes = [];
for (let i = 0; i < n; i++) {
sizes.push(Number(await readline()));
}
const dp = Array.from({ length: maxSize + 1 }, () => 0);
for (const size of sizes) {
const weight = Math.ceil(size / 512);
for (let i = maxSize; i >= weight; i--) {
dp[i] = Math.max(
dp[i],
dp[i - weight] + size
);
}
}
console.log(dp[maxSize]);
})();