using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var mod = 998_244_353; var ans = 1L; for (var i = 1; i < n; ++i) { ans = ans * Math.Min(a[i - 1], a[i]) % mod; } WriteLine(ans); } }