using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace kvalifikacija2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] k;
            string s;
            int n, m;
            k = Console.ReadLine().Split();
            n = Convert.ToInt32(k[0]);
            m = Convert.ToInt32(k[1]);
            int[] b = new int[m];
            k = Console.ReadLine().Split();
            for (int i = 0; i < m; i++)
                b[i] = Convert.ToInt32(k[i]);
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = i + 1;
            for (int i = 0; i <= n - m; i++)
                for (int j = 0; j < m; j++)
                    a[i + b[j] - 1] = a[i + j];
            s = Console.ReadLine();
            int c = Convert.ToInt32(s);
            long sum = 0;
            for (int i = 0; i < n; i++)
                sum += Convert.ToInt64(Math.Pow(Convert.ToDouble(c), Convert.ToDouble(i + 1)) * a[i]);
            Console.WriteLine(sum);
            Console.ReadKey();
        }
    }
}