#define _CRT_SECURE_NO_WARNINGS
#define MOD 998244353LL
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> P;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,-1)

ll san[] = { 1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 164017114, 492051342, 477909673, 435484666, 308209645, 924628935, 777398099, 335705591, 8872420, 26617260, 79851780, 239555340, 718666020, 159509354, 478528062, 437339833, 313775146, 941325438, 827487608, 485974118, 459678001, 380789650, 144124597, 432373791, 298877020, 896631060, 693404474, 83724716, 251174148, 753522444, 264078626, 792235878, 380218928, 142412431, 427237293, 283467526, 850402578, 554719028, 665912731, 1249487, 3748461, 11245383, 33736149, 101208447, 303625341, 910876023, 736139363, 211929383, 635788149, 909120094, 730871576, 196126022, 588378066, 766889845, 304180829, 912542487, 741138755, 226927559, 680782677, 45859325, 137577975, 412733925, 239957422, 719872266, 163128092, 489384276, 469908475, 411481072, 236198863, 708596589, 129301061, 387903183, 165465196, 496395588, 490942411, 474582880, 425504287, 278268508, 834805524, 507927866, 525539245, 578373382, 736875793, 214138673, 642416019, 929003704, 790522406, 375078512, 126991183, 380973549, 144676294, 434028882, 303842293, 911526879, 738091931, 217787087, 653361261, 961839430, 889029584, 670600046, 15311432, 45934296, 137802888, 413408664, 241981639, 725944917, 181346045, 544038135, 633870052, 903365803, 713608703, 144337403, 433012209, 300792274, 902376822, 710641760, 135436574, 406309722, 220684813, 662054439, 987918964, 967268186, 905315852, 719458850, 161887844, 485663532, 458746243, 377994376, 135738775, 407216325, 223404622, 670213866, 14152892, 42458676, 127376028, 382128084, 148139899, 444419697, 335014738, 6799861, 20399583, 61198749, 183596247, 550788741, 654121870, 964121257, 895875065, 691136489, 76920761, 230762283, 692286849, 80371841, 241115523, 723346569, 173551001, 520653003, 563714656, 692899615, 82210139, 246630417, 739891251, 223185047, 669555141, 12176717, 36530151, 109590453, 328771359, 986314077, 962453525, 890871869, 676126901, 31891997, 95675991, 287027973, 861083919, 586763051, 762044800, 289645694, 868937082, 610322540, 832723267, 501681095, 506798932, 522152443, 568212976, 706394575, 122695019, 368085057, 106010818, 318032454, 954097362, 865803380, 600921434, 804519949, 417071141, 252969070, 758907210, 280232924, 840698772, 525607610, 578578477, 737491078, 215984528, 647953584, 945616399, 840360491, 524592767, 575533948, 728357491, 188583767, 565751301, 699009550, 100539944, 301619832, 904859496, 718089782, 157780640, 473341920, 421781407, 267099868, 801299604, 407410106, 223985965, 671957895, 19384979, 58154937, 174464811, 523394433, 571938946, 717572485, 156228749, 468686247, 407814388, 225198811, 675596433, 30300593, 90901779, 272705337, 818116011, 457859327, 375333628, 127756531, 383269593, 151564426, 454693278, 365835481, 99262090, 297786270, 893358810, 683587724, 54274466, 162823398, 488470194, 467166229, 403254334, 211518649, 634555947, 905423488, 719781758, 162856568, 488569704, 467464759, 404149924, 214205419, 642616257, 929604418, 792324548, 380484938, 143210461, 429631383, 290649796, 871949388, 619359458, 859834021, 583013357, 750795718, 255898448, 767695344, 306597326, 919791978, 762887228, 292172978 };
ll ni[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 75497471, 150994942, 301989884, 603979768, 209715183, 419430366, 838860732, 679477111, 360709869, 721419738, 444595123, 889190246, 780136139, 562027925, 125811497, 251622994, 503245988, 8247623, 16495246, 32990492, 65980984, 131961968, 263923936, 527847872, 57451391, 114902782, 229805564, 459611128, 919222256, 840200159, 682155965, 366067577, 732135154, 466025955, 932051910, 865859467, 733474581, 468704809, 937409618, 876574883, 754905413, 511566473, 24888593, 49777186, 99554372, 199108744, 398217488, 796434976, 594625599, 191006845, 382013690, 764027380, 529810407, 61376461, 122752922, 245505844, 491011688, 982023376, 965802399, 933360445, 868476537, 738708721, 479173089, 958346178, 918448003, 838651653, 679058953, 359873553, 719747106, 441249859, 882499718, 766755083, 535265813, 72287273, 144574546, 289149092, 578298184, 158352015, 316704030, 633408060, 268571767, 537143534, 76042715, 152085430, 304170860, 608341720, 218439087, 436878174, 873756348, 749268343, 500292333, 2340313, 4680626, 9361252, 18722504, 37445008, 74890016, 149780032, 299560064, 599120128, 199995903, 399991806, 799983612, 601722871, 205201389, 410402778, 820805556, 643366759, 288489165, 576978330, 155712307, 311424614, 622849228, 247454103, 494908206, 989816412, 981388471, 964532589, 930820825, 863397297, 728550241, 458856129, 917712258, 837180163, 676115973, 353987593, 707975186, 417706019, 835412038, 672579723, 346915093, 693830186, 389416019, 778832038, 559419723, 120595093, 241190186, 482380372, 964760744, 931277135, 864309917, 730375481, 462506609, 925013218, 851782083, 705319813, 412395273, 824790546, 651336739, 304429125, 608858250, 219472147, 438944294, 877888588, 757532823, 516821293, 35398233, 70796466, 141592932, 283185864, 566371728, 134499103, 268998206, 537996412, 77748471, 155496942, 310993884, 621987768, 245731183, 491462366, 982924732, 967605111, 936965869, 875687385, 753130417, 508016481, 17788609, 35577218, 71154436, 142308872, 284617744, 569235488, 140226623, 280453246, 560906492, 123568631, 247137262, 494274524, 988549048, 978853743, 959463133, 920681913, 843119473, 687994593, 377744833, 755489666, 512734979, 27225605, 54451210, 108902420, 217804840, 435609680, 871219360, 744194367, 490144381, 980288762, 962333171, 926421989, 854599625, 710954897, 423665441, 847330882, 696417411, 394590469, 789180938, 580117523, 161990693, 323981386, 647962772, 297681191, 595362382, 192480411, 384960822, 769921644, 541598935, 84953517, 169907034, 339814068, 679628136, 361011919, 722023838, 445803323, 891606646, 784968939, 571693525, 145142697, 290285394, 580570788, 162897223, 325794446, 651588892, 304933431, 609866862, 221489371, 442978742, 885957484, 773670615, 549096877, 99949401, 199898802, 399797604, 799595208, 600946063, 203647773, 407295546, 814591092, 630937831, 263631309, 527262618, 56280883, 112561766, 225123532, 450247064, 900494128, 802743903, 607243453, 216242553, 432485106, 864970212, 731696071, 465147789 };

int main(void) {
	int n;
	cin >> n;
	vector<int> l(n);
	int sl = 0;
	REP(i, n) {
    	cin >> l[i];
		sl += l[i];
	}
	sort(l.begin(), l.end());
	vector<vector<ll>> arr = vector<vector<ll>>(sl + 1, vector<ll>(n + 1, 0));
	int imax = 0;
	vector<int> jmin = vector<int>(sl + 1, 400);
	vector<int> jmax = vector<int>(sl + 1, 1);
	arr[0][0] = 1;
	jmin[0] = 0;
	jmax[0] = 1;
	for (int a : l) {
		RREP(i, imax) {
			if (jmax[i + a] < jmax[i] + 1) jmax[i + a] = jmax[i] + 1;
			if (jmin[i + a] > jmin[i]) jmin[i + a] = jmin[i] + 1;
			FOR(j, jmin[i], jmax[i]) {
				arr[i + a][j + 1] = (arr[i + a][j + 1]+arr[i][j])%MOD;
			}
		}
		imax += a;
	}
	ll ans = (MOD*3+san[n] - ni[n] * 3 + 3) % MOD;
	int lo;
	if (sl % 2 == 1) lo = sl / 2 + 1;
	else lo = sl / 2;
	FOR(i, lo, sl + 1) {
		FOR(j, 1, n - 1) {
			ans += (MOD-ni[n - j - 1] + 1)*arr[i][j] * 6;
			ans %= MOD;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 214656