using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    static readonly Modulo modulo = new Modulo(998244353);
    static int N;
    static int[] a;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        a = new int[N];
        for (int i = 0; i < N; i++)
        {
            a[i] = Input.NextInt();
        }
        var total = a.Sum();
        var half = total / 2;
        var halfmod = total % 2;

        int n_all = modulo.Pow(3, N);

        int n_ng = 0;
        dp = new int[N + 1, N * 300 + 1];
        F(3);
        foreach (var redWeight in Enumerable.Range(half + halfmod, total - (half + halfmod) + 1))
        {
            var v = dp[a.Length, redWeight];
            n_ng = modulo.Plus(n_ng, v);
        }

        int n_ng2 = 0;
        dp = new int[N + 1, N * 300 + 1];
        F(2);
        if ((half + halfmod) * 2 <= total)
        {
            var v = dp[a.Length, half + halfmod];
            n_ng2 = modulo.Plus(n_ng2, v);
        }

        var ans = modulo.Plus(modulo.Minus(n_all, modulo.Mul(3, n_ng)), modulo.Mul(3, n_ng2));
        Console.WriteLine(ans);
    }

    static int[,] dp;

    static void F(int n_color_kind)
    {
        for (int i = 0; i <= N; i++)
        {
            for (int j = N * 300; j >= 0; j--)
            {
                int totalRed;
                if (i == 0)
                {
                    if (j == 0)
                    {
                        totalRed = 1;
                    }
                    else
                    {
                        totalRed = 0;
                    }
                }
                else
                {
                    // no add
                    var noAdd = modulo.Mul(dp[i - 1, j], n_color_kind - 1);
                    totalRed = noAdd;

                    // add 
                    var newWeight = j - a[i - 1];
                    if (newWeight >= 0)
                    {
                        var yesAdd = dp[i - 1, newWeight];
                        modulo.PlusEq(ref totalRed, yesAdd);
                    }
                }
                dp[i, j] = totalRed;
            }
        }
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public static void Lines(int N, out int[] a)
    {
        a = new int[N];
        for (int i = 0; i < N; i++)
        {
            var vals = LineInt();
            a[i] = vals[0];
        }
    }
    public static void Lines(int N, out int[] a, out int[] b)
    {
        a = new int[N];
        b = new int[N];
        for (int i = 0; i < N; i++)
        {
            var vals = LineInt();
            a[i] = vals[0];
            b[i] = vals[1];
        }
    }
    public static void Lines(int N, out int[] a, out int[] b, out int[] c)
    {
        a = new int[N];
        b = new int[N];
        c = new int[N];
        for (int i = 0; i < N; i++)
        {
            var vals = LineInt();
            a[i] = vals[0];
            b[i] = vals[1];
            c[i] = vals[2];
        }
    }
}

public class Modulo
{
    public int M { get; private set; }

    private static readonly List<int> m_facs = new List<int>() { 1, };

    public Modulo(int M = 1000000007)
    {
        this.M = M;
    }

    public int Mul(int a, int b)
    {
        return (int)(Math.BigMul(a, b) % M);
    }

    public int Fac(int n)
    {
        if (m_facs.Count <= n)
        {
            for (int i = m_facs.Count; i <= n; i++)
            {
                var facs_i = Mul(m_facs[i - 1], i);
                m_facs.Add(facs_i);
            }
        }
        return m_facs[n];
    }

    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }

    public int Div(int a, int b)
    {
        return Mul(a, Pow(b, M - 2));
    }

    public int Ncr(int n, int r)
    {
        if (n < r) { return 0; }
        if (n == r) { return 1; }
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }

    public int Plus(int a, int b)
    {
        PlusEq(ref a, b);
        return a;
    }

    public int Minus(int a, int b)
    {
        MinusEq(ref a, b);
        return a;
    }

    public void PlusEq(ref int a, int b)
    {
        a += b;
        a %= M;
    }

    public void MinusEq(ref int a, int b)
    {
        a -= b;
        if (a < 0)
            a += M;
        a %= M;
    }
}

Measured memory_bytes: 224856