using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Diagnostics; //using ModInt = AtCoder_MOD.ModInt;using static AtCoder_MOD.ModCalc; using ModInt = AtCoder_MOD.ModInt;using static AtCoder_MOD.ModCalc; namespace AtCoder_Main { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split().Select(long.Parse).ToArray(); ModInt ans = 0; ModInt pw = 1; for (var i = 0; i < N - 2; i++) pw *= 2; for(var i = 0; i < N; i++) { ModInt K = i + 1; ans += A[i] * (K + 1) * pw; } Console.WriteLine(ans); } } } namespace AtCoder_MOD { public interface IMod { int Mod { get; } // isprime ? } public interface INTTFriendly { int primitive_root { get; } } public readonly struct Mod1000000007 : IMod { public int Mod => 1000000007; } public readonly struct Mod998244353 : IMod, INTTFriendly { public int Mod => 998244353; public int primitive_root => 3; } public struct ModInt where T : IMod { private int value; // 0 <= x < mod 以外でも OK public ModInt(int x) { if (x < 0) x = (x % default(T).Mod) + default(T).Mod; else if (x >= default(T).Mod) x %= default(T).Mod; value = x; } public ModInt(long x) { if (x < 0) x = (x % default(T).Mod) + default(T).Mod; else if (x >= default(T).Mod) x %= default(T).Mod; value = (int)x; } // 0 <= x < mod public ModInt(uint x) => value = (int)x; public static ModInt operator +(ModInt a, ModInt b) { var nv = a.value + b.value; if (nv >= default(T).Mod) nv -= default(T).Mod; return new ModInt((uint)nv); } public static ModInt operator -(ModInt a, ModInt b) { var nv = a.value - b.value; if (nv < 0) nv += default(T).Mod; return new ModInt((uint)nv); } public static ModInt operator *(ModInt a, ModInt b) => new ModInt((uint)(((long)a.value * b.value) % default(T).Mod)); //符号 public static ModInt operator +(ModInt a) => a; public static ModInt operator -(ModInt a) => a.value == 0 ? a : new ModInt((uint)(default(T).Mod - a.value)); public ModInt Pow(long n) { if (n < 0) return Pow(-n).Pow(default(T).Mod - 2); var p = this; var ret = new ModInt(1u); while (n > 0) { if ((n & 1) != 0) ret *= p; p *= p; n >>= 1; } return ret; } //Todo Inv を ExtGcd での実装にしたい public ModInt Inverse() => this.Pow(default(T).Mod - 2); public static ModInt operator /(ModInt a, ModInt b) => (a * b.Inverse()); public static bool operator ==(ModInt a, ModInt b) => a.value == b.value; public static bool operator !=(ModInt a, ModInt b) => a.value != b.value; public override bool Equals(object obj) => obj is ModInt && this == (ModInt)obj; public override int GetHashCode() => value.GetHashCode(); public override string ToString() => value.ToString(); //キャスト public static implicit operator ModInt(int n) => new ModInt(n); public static implicit operator ModInt(long n) => new ModInt(n); public static explicit operator int(ModInt a) => a.value; public static explicit operator long(ModInt a) => a.value; } public static class ModCalc where T : IMod { static List> fac = new List>() { 1 }; static List> facinv; static int MAX_N; // Do Use Init(Max_n) Before using other functions public static void Init(int n) { MAX_N = n; for (int i = 1; i <= n; i++) fac.Add(fac.Last() * i); facinv = new List>() { fac[n].Inverse() }; for (int i = n; i > 0; i--) facinv.Add(facinv.Last() * i); facinv.Reverse(); } public static void Reset() { MAX_N = -1; fac.Clear(); facinv.Clear(); } public static ModInt Fac(int n) { Debug.Assert(n <= MAX_N); return fac[n]; } public static ModInt Finv(int n) { Debug.Assert(n <= MAX_N); return facinv[n]; } public static ModInt Comb(int n, int r) { Debug.Assert(n <= MAX_N); if (n < 0 || r < 0 || n < r) return 0; return fac[n] * facinv[n - r] * facinv[r]; } public static ModInt ModPow(long x, long n) => new ModInt(x).Pow(n); public static ModInt ModPow(int x, long n) => new ModInt((uint)x).Pow(n); public static ModInt ModPow(ModInt x, long n) => x.Pow(n); public static ModInt Inv(long x) => new ModInt(x).Inverse(); public static ModInt Inv(int x) => new ModInt((uint)x).Inverse(); public static List> GetFac() => fac; public static List> GetFacInv() => facinv; } }