import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class ladders467c {
    static BufferedReader __in;
    static PrintWriter __out;
    static StringTokenizer input;

    public static void main(String[] args) throws IOException {
        __in = new BufferedReader(new InputStreamReader(System.in));
        __out = new PrintWriter(new OutputStreamWriter(System.out));

        r();
        int n = ni(), m = ni(), k = ni(), a[] = ria(n);
        k = n - k * m;
        // dp[up to][# used - 1]
        long[][] dp = new long[n + 1][k + 1];
        for(long[] l : dp) {
            fill(l, LMAX - IBIG);
        }
        for(int i = 0; i <= n; ++i) {
            dp[i][0] = 0;
        }
        // either 1 apart or m apart
        for(int i = 1; i <= n; ++i) {
            if(i <= m) {
                // use/not use
                for(int j = 1; j <= k; ++j) {
                    dp[i][j] = min(dp[i - 1][j - 1] + a[i - 1], dp[i - 1][j]);
                }
            } else {
                // use/not use
                for(int j = 1; j <= k; ++j) {
                    dp[i][j] = min(dp[i - 1][j - 1] + a[i - 1],  dp[i - m - 1][j - 1] + a[i - 1]);
                }
            }
        }
        long sum = 0;
        for(int i : a) {
            sum += i;
        }
        long min = LMAX;
        for(int i = 1; i <= n; ++i) {
            min = min(min, dp[i][k]);
        }

        prln(sum - dp[n][k]);

        close();
    }

    // references
    // IBIG = 1e9 + 7
    // IRAND ~= 3e8
    // IMAX ~= 2e10
    // LMAX ~= 9e18
    // constants
    static final int IBIG = 1000000007;
    static final int IRAND = 327859546;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {assert x.length >= 2; return x.length == 2 ? min(x[0], x[1]) : min(x[0], minstarting(1, x));}
    static int minstarting(int offset, int... x) {assert x.length >= 2; return offset == x.length - 2 ? min(x[offset], x[offset + 1]) : min(x[offset], minstarting(offset + 1, x));}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {assert x.length >= 2; return x.length == 2 ? min(x[0], x[1]) : min(x[0], minstarting(1, x));}
    static long minstarting(int offset, long... x) {assert x.length >= 2; return offset == x.length - 2 ? min(x[offset], x[offset + 1]) : min(x[offset], minstarting(offset + 1, x));}
    static int powi(int a, int b) {if(a == 0) return 0; int ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if(a == 0) return 0; long ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int floori(double d) {return (int)d;}
    static int ceili(double d) {return (int)ceil(d);}
    static long floorl(double d) {return (long)d;}
    static long ceill(double d) {return (long)ceil(d);}
    // input
    static void r() throws IOException {input = new StringTokenizer(__in.readLine());}
    static int ri() throws IOException {return Integer.parseInt(__in.readLine());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Integer.parseInt(input.nextToken()); return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Long.parseLong(input.nextToken()); return a;}
    static char[] rcha() throws IOException {return __in.readLine().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static int ni() {return Integer.parseInt(input.nextToken());}
    static long nl() {return Long.parseLong(input.nextToken());}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {__out.println("yes");}
    static void pry() {__out.println("Yes");}
    static void prY() {__out.println("YES");}
    static void prno() {__out.println("no");}
    static void prn() {__out.println("No");}
    static void prN() {__out.println("NO");}
    static void pryesno(boolean b) {__out.println(b ? "yes" : "no");};
    static void pryn(boolean b) {__out.println(b ? "Yes" : "No");}
    static void prYN(boolean b) {__out.println(b ? "YES" : "NO");}
    static void prln(int... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), i++); __out.println(a[a.length - 1]);}
    static void prln(long... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), i++); __out.println(a[a.length - 1]);}
    static void flush() {__out.flush();}
    static void close() {__out.close();}
    // debug
    static void debug(String desc, int... a) {System.out.print(desc); System.out.print(": "); for(int i = 0, len = a.length - 1; i < len; System.out.print(a[i]), System.out.print(", "), i++); System.out.println(a[a.length - 1]);}
    static void debug(String desc, long... a) {System.out.print(desc); System.out.print(": "); for(int i = 0, len = a.length - 1; i < len; System.out.print(a[i]), System.out.print(", "), i++); System.out.println(a[a.length - 1]);}
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf467c {

    public static void main(String[] args) throws IOException {
        int n = rni(), m = ni(), k = ni(), p[] = ria(n);
        long dp[][] = new long[k + 1][n - m + 1], sum[] = new long[n - m + 1];
        for(int i = 0; i < m; ++i) {
            sum[0] += p[i];
        }
        for(int i = 0; i < n - m; ++i) {
            sum[i + 1] = sum[i] + p[i + m] - p[i];
        }
        for(int i = 1; i <= k; ++i) {
            long max = 0;
            for(int j = 0; j <= n - m; ++j) {
                if(j >= m) {
                    max = max(max, dp[i - 1][j - m]);
                }
                dp[i][j] = max + sum[j];
            }
        }
        /* for(long[] i : dp) {
            prln(i);
        } */
        prln(maxof(dp[k]));
        close();
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IRAND ~= 3e8
    // IMAX ~= 2e10
    // LMAX ~= 9e18
    // constants
    static final int IBIG = 1000000007;
    static final int IRAND = 327859546;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {return x.length == 1 ? x[0] : x.length == 2 ? min(x[0], x[1]) : min(x[0], minstarting(1, x));}
    static int minstarting(int offset, int... x) {assert x.length > 2; return offset == x.length - 2 ? min(x[offset], x[offset + 1]) : min(x[offset], minstarting(offset + 1, x));}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {return x.length == 1 ? x[0] : x.length == 2 ? min(x[0], x[1]) : min(x[0], minstarting(1, x));}
    static long minstarting(int offset, long... x) {assert x.length > 2; return offset == x.length - 2 ? min(x[offset], x[offset + 1]) : min(x[offset], minstarting(offset + 1, x));}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {return x.length == 1 ? x[0] : x.length == 2 ? max(x[0], x[1]) : max(x[0], maxstarting(1, x));}
    static int maxstarting(int offset, int... x) {assert x.length > 2; return offset == x.length - 2 ? max(x[offset], x[offset + 1]) : max(x[offset], maxstarting(offset + 1, x));}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {return x.length == 1 ? x[0] : x.length == 2 ? max(x[0], x[1]) : max(x[0], maxstarting(1, x));}
    static long maxstarting(int offset, long... x) {assert x.length > 2; return offset == x.length - 2 ? max(x[offset], x[offset + 1]) : max(x[offset], maxstarting(offset + 1, x));}
    static int powi(int a, int b) {if(a == 0) return 0; int ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if(a == 0) return 0; long ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int floori(double d) {return (int)d;}
    static int ceili(double d) {return (int)ceil(d);}
    static long floorl(double d) {return (long)d;}
    static long ceill(double d) {return (long)ceil(d);}
    static void shuffle(int[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static <T> void shuffle(T[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); T swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void sort(int[] a) {shuffle(a); Arrays.sort(a);}
    static void sort(long[] a) {shuffle(a); Arrays.sort(a);}
    static void sort(double[] a) {shuffle(a); Arrays.sort(a);}
    static void qsort(int[] a) {Arrays.sort(a);}
    static void qsort(long[] a) {Arrays.sort(a);}
    static void qsort(double[] a) {Arrays.sort(a);}
    static int randInt(int min, int max) {return rand.nextInt(max - min + 1) + min;}
    // input
    static void r() throws IOException {input = new StringTokenizer(__in.readLine());}
    static int ri() throws IOException {return Integer.parseInt(__in.readLine());}
    static long rl() throws IOException {return Long.parseLong(__in.readLine());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Integer.parseInt(input.nextToken()); return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Long.parseLong(input.nextToken()); return a;}
    static char[] rcha() throws IOException {return __in.readLine().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static int rni() throws IOException {input = new StringTokenizer(__in.readLine()); return Integer.parseInt(input.nextToken());}
    static int ni() {return Integer.parseInt(input.nextToken());}
    static long rnl() throws IOException {input = new StringTokenizer(__in.readLine()); return Long.parseLong(input.nextToken());}
    static long nl() {return Long.parseLong(input.nextToken());}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {__out.println("yes");}
    static void pry() {__out.println("Yes");}
    static void prY() {__out.println("YES");}
    static void prno() {__out.println("no");}
    static void prn() {__out.println("No");}
    static void prN() {__out.println("NO");}
    static void pryesno(boolean b) {__out.println(b ? "yes" : "no");};
    static void pryn(boolean b) {__out.println(b ? "Yes" : "No");}
    static void prYN(boolean b) {__out.println(b ? "YES" : "NO");}
    static void prln(int... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); __out.println(a[a.length - 1]);}
    static void prln(long... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); __out.println(a[a.length - 1]);}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for(int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i); if(n >= 0) __out.println(iter.next());}
    static void h() {__out.println("hlfd");}
    static void flush() {__out.flush();}
    static void close() {__out.close();}
}


import java.io.*;
import java.util.*;
//import java.util.StringTokenizer;
public class Q2 {
    public static void main(String[] args)throws IOException{
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          PrintWriter writer = new PrintWriter(System.out);
          StringTokenizer st=new StringTokenizer(br.readLine()," ");
          int n=Integer.parseInt(st.nextToken());
          int m=Integer.parseInt(st.nextToken());
          int k=Integer.parseInt(st.nextToken());
          int[] a=new int[n+1];
          st=new StringTokenizer(br.readLine()," ");
          for(int i=1;i<=n;i++)
           a[i]=Integer.parseInt(st.nextToken());
          long[] sum=new long[n+1];
          for(int i=1;i<=n;i++)
           sum[i]=sum[i-1]+(long)(a[i]);
          long[][] dp=new long[k+1][n+1];
          for(int i=1;i<=k;i++)
          {
             for(int j=1;j<=n;j++)
             {
                if(i==1)
                {
                   if(j-m+1>=1)
                    dp[i][j]=Math.max(sum[j]-sum[j-m],dp[i][j-1]);
                }
                else
                {
                   if(j-m+1>=1&&dp[i-1][j-m]!=0)
                   {
                      dp[i][j]=Math.max(sum[j]-sum[j-m]+dp[i-1][j-m],dp[i][j-1]);
                   }
                }
             }
          }
          writer.println(dp[k][n]);
          writer.flush();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter pw=new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        //BufferedReader reader=new BufferedReader(new FileReader("input.txt"));
        //PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //Scanner scanner=new Scanner(System.in);
        Reader scanner = new Reader();

        int n=scanner.nextInt();
        int m=scanner.nextInt();
        int k=scanner.nextInt();
        Long[] a=new Long[n+1];
        Long[] b=new Long[n+1];
        a[0]=0L;
        b[0]=0L;
        for (int i = 1; i <=n ; i++) {
            a[i]=scanner.nextLong();
            b[i]=a[i];
        }
        for (int i = m-1; i >0 ; i--) {
            a[m]+=a[i];
        }
        for (int i = m+1; i <=n ; i++) {
            a[i]+=(a[i-1]-b[i-m]);
        }
        long[][] dp=new long[n+1][k+1];
        for (int i = m; i <=n ; i++) {
            for (int j = 1; j <=k ; j++) {
                    dp[i][j]=Math.max(dp[i-1][j],dp[i-m][j-1]+a[i]);
            }
        }
        System.out.println(dp[n][k]);

        pw.close();

    }
    static boolean isInt(double n){
        if (n>10e8-1)return false;
        else return n == (long) n;
    }
    static long s(long n){
        String s=String.valueOf(n);
        long sum=0L;
        for (int i = 0; i <s.length() ; i++) {
            sum+=s.charAt(i)-48;
        }
        return sum;
    }
    static Vector<Integer> set=new Vector<>();
    static void com(int m2,int u2){
        if (u2>0){
            com(m2+1,u2-1);
            com(m2-1,u2-1);
        }
        else
            set.add(m2);

    }

    static int find(int n,int[] p){
        if (p[n]==n)return n;
        return p[n]=find(p[n],p);
    }
    static void union(int a,int b,int[] p){
        int aRoot=find(a,p);
        int bRoot=find(b,p);
        if (aRoot==bRoot)return;
        p[bRoot]=aRoot;
        //level[aRoot]+=level[bRoot];
    }
}
class node implements Comparable<node>{
    Integer no;
    Integer cost;
    Vector<node> adj=new Vector<>();
    public node(Integer no, Integer cost) {
        this.no = no;
        this.cost = cost;
    }

    @Override
    public String toString() {
        return "node{" +
                "no=" + no +
                ", cost=" + cost +
                '}';
    }

    @Override
    public int compareTo(node o) {
        return o.cost-this.cost;
    }
}
class edge implements Comparable<edge>{
    tuple u;
    Double cost;
    public edge(tuple u, Double cost) {
        this.u = u;
        this.cost = cost;
    }
    @Override
    public int compareTo(edge o) {
        return this.cost.compareTo(o.cost);
    }

    @Override
    public String toString() {
        return "edge{" +
                "u=" + u +
                ", cost=" + cost +
                '}';
    }
}
///*
class tuple implements Comparable<tuple>{
    double a;
    double b;
    tuple(double a, double b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public int compareTo(tuple o) {
        return (int) (this.a-o.a);
    }
}

//*/
class Reader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException {
        byte[] buf = new byte[64];
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n') break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
        if (neg) return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null) return;
        din.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter pw=new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        //BufferedReader reader=new BufferedReader(new FileReader("input.txt"));
        //PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //Scanner scanner=new Scanner(System.in);
        Reader scanner = new Reader();

        int n=scanner.nextInt();
        int m=scanner.nextInt();
        int k=scanner.nextInt();
        Long[] a=new Long[n+1];
        Long[] b=new Long[n+1];
        a[0]=0L;
        b[0]=0L;
        for (int i = 1; i <=n ; i++) {
            a[i]=scanner.nextLong();
            b[i]=a[i];
        }
        for (int i = m-1; i >0 ; i--) {
            a[m]+=a[i];
        }
        for (int i = m+1; i <=n ; i++) {
            a[i]+=(a[i-1]-b[i-m]);
        }
        Arrays.sort(a);
        long sum=0L;
        for (int i = 0; i <k ; i++) {
            sum+=a[n--];
        }
        System.out.println(sum);

        pw.close();

    }
    static boolean isInt(double n){
        if (n>10e8-1)return false;
        else return n == (long) n;
    }
    static long s(long n){
        String s=String.valueOf(n);
        long sum=0L;
        for (int i = 0; i <s.length() ; i++) {
            sum+=s.charAt(i)-48;
        }
        return sum;
    }
    static Vector<Integer> set=new Vector<>();
    static void com(int m2,int u2){
        if (u2>0){
            com(m2+1,u2-1);
            com(m2-1,u2-1);
        }
        else
            set.add(m2);

    }

    static int find(int n,int[] p){
        if (p[n]==n)return n;
        return p[n]=find(p[n],p);
    }
    static void union(int a,int b,int[] p){
        int aRoot=find(a,p);
        int bRoot=find(b,p);
        if (aRoot==bRoot)return;
        p[bRoot]=aRoot;
        //level[aRoot]+=level[bRoot];
    }
}
class node implements Comparable<node>{
    Integer no;
    Integer cost;
    Vector<node> adj=new Vector<>();
    public node(Integer no, Integer cost) {
        this.no = no;
        this.cost = cost;
    }

    @Override
    public String toString() {
        return "node{" +
                "no=" + no +
                ", cost=" + cost +
                '}';
    }

    @Override
    public int compareTo(node o) {
        return o.cost-this.cost;
    }
}
class edge implements Comparable<edge>{
    tuple u;
    Double cost;
    public edge(tuple u, Double cost) {
        this.u = u;
        this.cost = cost;
    }
    @Override
    public int compareTo(edge o) {
        return this.cost.compareTo(o.cost);
    }

    @Override
    public String toString() {
        return "edge{" +
                "u=" + u +
                ", cost=" + cost +
                '}';
    }
}
///*
class tuple implements Comparable<tuple>{
    double a;
    double b;
    tuple(double a, double b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public int compareTo(tuple o) {
        return (int) (this.a-o.a);
    }
}

//*/
class Reader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException {
        byte[] buf = new byte[64];
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n') break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
        if (neg) return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null) return;
        din.close();
    }
}


import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        StringTokenizer st1 = new StringTokenizer(br.readLine());
        br.close();
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        int[] array = new int[n];
        for(int i=0;i<n;i++){
            array[i]=Integer.parseInt(st1.nextToken());
        }
        long[] dp = new long[n-m+1];
        long[] presum = new long[n+1];
        for(int i=1;i<=n;i++){
            presum[i]=presum[i-1]+(long)array[i-1];
        }
        for(int i=0;i<=n-m;i++){
            dp[i]=presum[i+m]-presum[i];
        }
        Arrays.sort(dp);
        long ans = 0;
        int x = n-m;
        while(k-->0){
            ans+=dp[x];
            x--;
        }
        System.out.println(ans);
    }
}


import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    static int m;
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        StringTokenizer st1 = new StringTokenizer(br.readLine());
        br.close();
        int n = Integer.parseInt(st.nextToken());
        m = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        int[] array = new int[n];
        for(int i=0;i<n;i++){
            array[i]=Integer.parseInt(st1.nextToken());
        }
        long[] presum = new long[n+1];
        for(int i=1;i<=n;i++){
            presum[i]=presum[i-1]+(long)array[i-1];
        }
        long[][] dp = new long[n+1][k];
        for(int i=0;i<=n;i++){
            Arrays.fill(dp[i],-1);
        }
        System.out.println(findAns(dp,presum,n,k-1));
    }
    static long findAns(long[][] dp,long[] presum,int n,int k){
        if(n-m<0 || k<0){
            return 0;
        }
        if(dp[n][k]==-1){
            dp[n][k]=Math.max(findAns(dp,presum,n-m,k-1)+presum[n]-presum[n-m],findAns(dp,presum,n-1,k));
        }
        return dp[n][k];
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
//import java.util.stream.Collectors;
public final class Enraged
{
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    public static Reader sc = new Reader();
//        public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//    public static Scanner sc = new Scanner(System.in);
    public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    //    public static OutputStream out2 = new BufferedOutputStream (System.out);
    public static int n, m, i, j, k, u, v;
    public static long inf = (long)1e18;
    public static long[][][] dp;
    public static int[] arr;
    public static void main(String[] args) throws IOException
    {
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        arr = new int[n+10];
        dp = new long[n+10][m+100][k+100];
        for(i = 0; i <= n; i++)
            for(j = 0; j <= m; j++)
                Arrays.fill(dp[i][j], -1);
        for(i = 1; i <= n; i++)
        {
            arr[i] = sc.nextInt();
            if(i > 1)
                arr[i] += arr[i-1];
        }
        out.write(recur(0, 0, 0)+"");
        out.flush();
    }
    public static long recur(int i, int cnt, int s)
    {
        if(dp[i][cnt][s] != -1)
            return dp[i][cnt][s];
        if(i == n)
        {
            if(cnt == 0)
                return dp[i][cnt][s] = s == k ? 0: -inf;
            if(cnt != m || s != k-1)
                return dp[i][cnt][s] = -inf;
            return dp[i][cnt][s] = arr[i]-arr[i-m];
        }
        if(cnt == m)
            return dp[i][cnt][s] = recur(i, 0, s + 1) + arr[i] - arr[i-m];
        if(cnt == 0)
            return dp[i][cnt][s] = Math.max(recur(i+1, 1, s), recur(i+1, 0, s));
        return dp[i][cnt][s] = recur(i+1, cnt + 1, s);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
//import java.util.stream.Collectors;
public final class Enraged
{
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    public static Reader sc = new Reader();
//        public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//    public static Scanner sc = new Scanner(System.in);
    public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    //    public static OutputStream out2 = new BufferedOutputStream (System.out);
    public static int n, m, i, j, k, u, v;
    public static long inf = (long)1e18;
    public static long[][][] dp;
    public static int[] arr;
    public static void main(String[] args) throws IOException
    {
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        arr = new int[n+10];
        dp = new long[n+10][m+10][k+10];
        for(i = 0; i <= n; i++)
            for(j = 0; j <= m; j++)
                Arrays.fill(dp[i][j], -1);
        for(i = 1; i <= n; i++)
        {
            arr[i] = sc.nextInt();
            if(i > 1)
                arr[i] += arr[i-1];
        }
        out.write(recur(0, 0, 0)+"");
        out.flush();
    }
    public static long recur(int i, int cnt, int s)
    {
        if(dp[i][cnt][s] != -1)
            return dp[i][cnt][s];
        if(i == n)
        {
            if(cnt == 0)
                return dp[i][cnt][s] = s == k ? 0: -inf;
            if(cnt != m || s != k-1)
                return dp[i][cnt][s] = -inf;
            return dp[i][cnt][s] = arr[i]-arr[i-m];
        }
        if(cnt == m)
            return dp[i][cnt][s] = recur(i, 0, s + 1) + arr[i] - arr[i-m];
        if(cnt == 0)
            return dp[i][cnt][s] = Math.max(recur(i+1, 1, s), recur(i+1, 0, s));
        return dp[i][cnt][s] = recur(i+1, cnt + 1, s);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
//import java.util.stream.Collectors;
public final class Enraged
{
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    public static Reader sc = new Reader();
//        public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//    public static Scanner sc = new Scanner(System.in);
    public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    //    public static OutputStream out2 = new BufferedOutputStream (System.out);
    public static int n, m, i, j, k, u, v;
    public static long inf = Long.MIN_VALUE;
    public static long[][] dp;
    public static long[] arr;
    public static void main(String[] args) throws IOException
    {
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        arr = new long[n+1];
        dp = new long[n+1][k+1];
        for(i = 0; i <= n; i++)
            Arrays.fill(dp[i], -1);
        for(i = 1; i <= n; i++)
        {
            arr[i] = sc.nextInt();
            if(i > 1)
                arr[i] += arr[i-1];
        }
        out.write(recur(1, 0)+"");
        out.flush();
    }
    public static long recur(int i, int s)
    {
        if(s == k)
            return 0;
        if(i + m - 1 > n)
            return inf;
        if(dp[i][s] != -1)
            return dp[i][s];
        return dp[i][s] = Math.max(recur(i + m, s + 1) + arr[i+m-1]-arr[i-1], recur(i + 1, s));
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
//import java.util.stream.Collectors;
public final class Enraged
{
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    public static Reader sc = new Reader();
//        public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//    public static Scanner sc = new Scanner(System.in);
    public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    //    public static OutputStream out2 = new BufferedOutputStream (System.out);
    public static int n, m, i, j, k, u, v;
    public static long inf = (long)1e18;
    public static long[][] dp;
    public static int[] arr;
    public static void main(String[] args) throws IOException
    {
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        arr = new int[n+1];
        dp = new long[n+1][k+1];
        for(i = 0; i <= n; i++)
                Arrays.fill(dp[i], -1);
        for(i = 1; i <= n; i++)
        {
            arr[i] = sc.nextInt();
            if(i > 1)
                arr[i] += arr[i-1];
        }
        out.write(recur(1, 0)+"");
        out.flush();
    }
    public static long recur(int i, int s)
    {
        if(s == k)
            return 0;
        if(i > n)
            return -inf;
        if(dp[i][s] != -1)
            return dp[i][s];
        if(i + m - 1 > n)
            return -inf;
        return dp[i][s] = Math.max(recur(i + m, s + 1) + arr[i+m-1]-arr[i-1], recur(i + 1, s));
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_467C {
    public static void main(String[] args) throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st1 = new StringTokenizer(s.readLine());
        int n = Integer.parseInt(st1.nextToken());
        int m = Integer.parseInt(st1.nextToken());
        int k = Integer.parseInt(st1.nextToken());

        long[] arr = new long[n];
        StringTokenizer st2 = new StringTokenizer(s.readLine());
        for(int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(st2.nextToken());
        }

        long[] comp = new long[n-m+1];
        long sum = 0;
        for(int i = 0; i < m; i++) {
            sum += arr[i];
        }
        comp[0] = sum;
        for(int i = m; i < n; i++) {
            sum += arr[i]-arr[i-m];
            comp[i-m+1] = sum;
        }

        long[][] dp = new long[k][n-m+1];
        long max = comp[0];
        for(int i = 0; i < n-m+1; i++) {
            if(comp[i] > max) max = comp[i];
            dp[0][i] = max;
        }

        for(int i = 1; i < k; i++) {
            for(int j = i*m; j < n-m+1; j++) {
                dp[i][j] = Math.max(dp[i-1][j-m] + comp[j], dp[i][j-1]);
            }
        }

        System.out.println(dp[k-1][n-m]);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GeorgeAndJob {
    public static void main(String[] args)throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long [] arr = new long[n+1];
        st = new StringTokenizer(bf.readLine());
        for (int i = 1; i < n+1; i++) {
            arr[i]= Integer.parseInt(st.nextToken());
        }
        long sum = 0;
        long[] prefix_sum = new long[n-m+2];
        for (int i = 1; i <=m; i++) {
           prefix_sum[1] +=arr[i];
        }
        sum=prefix_sum[1];
        int j=2;
        for (int i = m+1;i < n+1; i++) {
            sum += arr[i];
            sum -= arr[j-1];
            prefix_sum[j] = sum;
            j++;
        }
        long [][] dp = new long[n-m+2][k+1];
        for (int i = 1; i < n-m+2; i++) {
            for (int l = 1; l < k+1; l++) {
                dp[i][l]=Math.max(prefix_sum[i]+dp[i-1][l-1],dp[i-1][l]);
            }
        }
        System.out.print(dp[n-m+1][k]);

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GeorgeAndJob {
    public static void main(String[] args)throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long [] arr = new long[n+1];
        st = new StringTokenizer(bf.readLine());
        for (int i = 1; i < n+1; i++) {
            arr[i]= Integer.parseInt(st.nextToken());
        }
        long[] prefix_sum = new long[n+1];
        for (int i = 1; i <=n; i++) {
           prefix_sum[i] =prefix_sum[i-1]+arr[i];
        }
        long [][] dp = new long[n+1][k+1];
        for (int i = 1; i < n+1; i++) {
            for (int l = 1; l < k+1; l++) {
                dp[i][l]=dp[i-1][l];
                if (i>=m)
                    dp[i][l]=Math.max(prefix_sum[i]-prefix_sum[i-m]+dp[i-m][l-1],dp[i-1][l]);
            }
        }
        System.out.print(dp[n][k]);

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GeorgeAndJob {
    public static int m;
    public static long k(long[]arr,int n,int k){
        if (n<=0||k<=0)
            return 0;

        return Math.max(arr[n-1]+k(arr,n-m,k-1),k(arr,n-1,k));
    }
    public static void main(String[] args)throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int n = Integer.parseInt(st.nextToken());
        m = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long [] arr = new long[n+1];
        st = new StringTokenizer(bf.readLine());
        for (int i = 1; i < n+1; i++) {
            arr[i]= Integer.parseInt(st.nextToken());
        }
        long sum = 0;
        long[] prefix_sum = new long[n-m+1];
        for (int i = 1; i <=m; i++) {
           prefix_sum[0] +=arr[i];
        }
        sum=prefix_sum[0];
        int j=1;
        for (int i = m+1;i < n+1; i++) {
            sum += arr[i];
            sum -= arr[j];
            prefix_sum[j] = sum;
            j++;
        }
        System.out.print(k(prefix_sum,n-m+1,k));
    }
}


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def solve():
    n, m, x = read_tuple(int)
    keyboard = []
    symbols = {}
    for _ in range(n):
        keyboard.append(list(input().replace('\n', '')))
        for k in keyboard[-1]:
            symbols[k] = None

    for i in range(n):
        for j in range(m):
            curr = keyboard[i][j]
            if curr != 'S':
                for k in range(n):
                    for l in range(m):
                        if keyboard[k][l] == 'S':
                            dist = (i - k) ** 2 + (j - l) ** 2 <= x ** 2
                            if symbols[curr] == None:
                                symbols[curr] = dist
                            else:
                                symbols[curr] = max(symbols[curr], dist)
    ans_exist = True
    ans = 0
    q = int(input())
    string = input().replace('\n', '')
    for char in string:
        if char in symbols:
            pass
        elif char.lower() in symbols:
            if symbols[char.lower()] == None:
                ans_exist = False
            elif symbols[char.lower()] == False:
                ans += 1
        else:
            ans_exist = False
    if ans_exist:
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    solve()


##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############

"""
 Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.
"""
from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii():  return int(input())
def si():  return input()
def mi():  return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li():  return list(mi())

def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy
import sys
input = sys.stdin.readline
scanner = lambda: int(input())
string = lambda: input().rstrip()
get_list = lambda: list(read())
read = lambda: map(int, input().split())
get_float = lambda: map(float, input().split())
# from bisect import bisect_left as lower_bound;
# from bisect import bisect_right as upper_bound;
# from math import ceil, factorial;

def ceil(x):
    if x != int(x):
        x = int(x) + 1
    return x

def factorial(x, m):
	val = 1
	while x>0:
		val = (val * x) % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp;

## gcd function
def gcd(a,b):
    if b == 0:
        return a;
    return gcd(b, a % b);

## lcm function
def lcm(a, b):
	return (a * b) // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

## nCr function efficient using Binomial Cofficient
def nCr(n, k):
	if k > n:
		return 0
	if(k > n - k):
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

## upper bound function code -- such that e in a[:i] e < x;

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p):
    if y == 0:
        return 1
    res = 1
    x = x % p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) :
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b;

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];

    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;

# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n):
    prime = [True for i in range(n+1)]
    prime[0], prime[1] = False, False
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

# Euler's Toitent Function phi
def phi(n) :

    result = n
    p = 2
    while(p * p<= n) :
        if (n % p == 0) :
            while (n % p == 0) :
                n = n // p
            result = result * (1.0 - (1.0 / (float) (p)))
        p = p + 1
    if (n > 1) :
        result = result * (1.0 - (1.0 / (float)(n)))

    return (int)(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False

	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e5 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
spf = [0 for i in range(MAXN)]
# spf_sieve();
def factoriazation(x):
    res = []
    for i in range(2, int(x ** 0.5) + 1):
    	while x % i == 0:
    		res.append(i)
    		x //= i
    if x != 1:
   		res.append(x)
    return res
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()));

def float_array():
    return list(map(float, input().strip().split()));

## taking string array input
def str_array():
    return input().strip().split();

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		# print(low, mid, high)
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

## for checking any conditions
def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

## for sorting according to second position
def sortSecond(val):
	return val[1]

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');
alphs = "abcdefghijklmnopqrstuvwxyz"

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal
# from sys import stdout
# import numpy as np
"""
_______________
rough work here
_______________

vasya has an unusual keyboard at his disposal:
it is rectangular and it has n rows
containing m keys in each row
keys are of two type
some are lowercase latin letters on them
some convert lowercase letters to uppercase.
vasya can press one or two keys with one hand
he can only press two keys if:
euclidean distance between the centers of the
keys does not exceed x
the keys are squares with a side equal to 1
no empty spaces between neighbouring keys

"""

def solve():
    n, m, k = read()
    keyboard = [string() for x in range(n)]
    mp = {}
    shifts = []
    for i in range(n):
        for j in range(m):
            if keyboard[i][j] == "S":
                shifts.append([i, j])
                continue
            mp[keyboard[i][j]] = [i, j]
    # print(mp)
    # print(shifts)
    q = scanner()
    text = string()
    c = 0
    for x in text:
        if mp.get(x.lower()) == None:
            print(-1)
            return
        if x != x.lower():
            # print(x)
            if len(shifts) == 0:
                print(-1)
                return
            for y in shifts:
                # print((mp[x.lower()][0] - y[0]) ** 2 + (mp[x.lower()][1] - y[1]) ** 2)
                if (mp[x.lower()][0] - y[0]) ** 2 + (mp[x.lower()][1] - y[1]) ** 2 <= k ** 2:
                    # print("yes", x)
                    break
            else:
                c += 1
    print(c)

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    # sys.stdin = open("input.txt", "r")
    # sys.stdout = open("output.txt", "w")
    t = 1
    for i in range(t):
    	solve()
    #dmain()

# Comment Read()
	# fin_time = datetime.now()
# 	print("Execution time (for loop): ", (fin_time-init_time))


##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############

"""
 Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.
"""
from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii():  return int(input())
def si():  return input()
def mi():  return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li():  return list(mi())

def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy
import sys
input = sys.stdin.readline
scanner = lambda: int(input())
string = lambda: input().rstrip()
get_list = lambda: list(read())
read = lambda: map(int, input().split())
get_float = lambda: map(float, input().split())
# from bisect import bisect_left as lower_bound;
# from bisect import bisect_right as upper_bound;
# from math import ceil, factorial;

def ceil(x):
    if x != int(x):
        x = int(x) + 1
    return x

def factorial(x, m):
	val = 1
	while x>0:
		val = (val * x) % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp;

## gcd function
def gcd(a,b):
    if b == 0:
        return a;
    return gcd(b, a % b);

## lcm function
def lcm(a, b):
	return (a * b) // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

## nCr function efficient using Binomial Cofficient
def nCr(n, k):
	if k > n:
		return 0
	if(k > n - k):
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

## upper bound function code -- such that e in a[:i] e < x;

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p):
    if y == 0:
        return 1
    res = 1
    x = x % p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) :
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b;

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];

    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;

# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n):
    prime = [True for i in range(n+1)]
    prime[0], prime[1] = False, False
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

# Euler's Toitent Function phi
def phi(n) :

    result = n
    p = 2
    while(p * p<= n) :
        if (n % p == 0) :
            while (n % p == 0) :
                n = n // p
            result = result * (1.0 - (1.0 / (float) (p)))
        p = p + 1
    if (n > 1) :
        result = result * (1.0 - (1.0 / (float)(n)))

    return (int)(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False

	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e5 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
spf = [0 for i in range(MAXN)]
# spf_sieve();
def factoriazation(x):
    res = []
    for i in range(2, int(x ** 0.5) + 1):
    	while x % i == 0:
    		res.append(i)
    		x //= i
    if x != 1:
   		res.append(x)
    return res
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()));

def float_array():
    return list(map(float, input().strip().split()));

## taking string array input
def str_array():
    return input().strip().split();

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		# print(low, mid, high)
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

## for checking any conditions
def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

## for sorting according to second position
def sortSecond(val):
	return val[1]

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');
alphs = "abcdefghijklmnopqrstuvwxyz"

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal
# from sys import stdout
# import numpy as np
"""
_______________
rough work here
_______________

vasya has an unusual keyboard at his disposal:
it is rectangular and it has n rows
containing m keys in each row
keys are of two type
some are lowercase latin letters on them
some convert lowercase letters to uppercase.
vasya can press one or two keys with one hand
he can only press two keys if:
euclidean distance between the centers of the
keys does not exceed x
the keys are squares with a side equal to 1
no empty spaces between neighbouring keys

"""

def solve():
    n, m, k = read()
    keyboard = [string() for x in range(n)]
    mp = {}
    shifts = []
    for i in range(n):
        for j in range(m):
            if keyboard[i][j] == "S":
                shifts.append([i, j])
    one_or_two = {}
    for x in alphs:
        one_or_two[x] = False
    for i in range(n):
        for j in range(m):
            now = keyboard[i][j]
            if now == "S": continue
            mp[now] = True
            for y in shifts:
                # print(i, j, y, now)
                if (i - y[0]) ** 2 + (j - y[1]) ** 2 <= k ** 2:
                    one_or_two[now] = True
                    break
    # print(one_or_two)
    # print(mp)

    q = scanner()
    text = string()
    c = 0
    # j = 0
    # ans = []
    for x in text:
        if mp.get(x.lower()) == None:
            print(-1)
            return
        if x != x.lower():
            if len(shifts) == 0:
                print(-1)
                return
            if one_or_two[x.lower()] == False:
                c += 1
                # ans.append(x)
    print(c)
    # print(ans)

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    # sys.stdin = open("input.txt", "r")
    # sys.stdout = open("output.txt", "w")
    t = 1
    for i in range(t):
    	solve()
    #dmain()

# Comment Read()
	# fin_time = datetime.now()
# 	print("Execution time (for loop): ", (fin_time-init_time))


class Point
	attr_accessor :x
	attr_accessor :y

	def initialize(x1,y1)
    	@x = x1.to_f
    	@y = y1.to_f
  	end

	def distance_to(x1,y1)
    	dx = @x - x1
    	dy = @y - y1
    	d = Math.sqrt(dx * dx + dy * dy)
    	return(d)
  	end
end

n,m,xx = gets.chomp.split(/ /).map!{|x| x.to_i}
bbb = []
sss = []
mmm = Hash::new
mmm.default = -1
for i in 0..n-1
	bbb.push(gets.chomp)
	for j in 0..m-1
		sss.push(Point.new(j,i)) if bbb[i][j] == "S"
	end
end

for i in 0..n-1
	for j in 0..m-1
		if bbb[i][j] != "S" then
			wk = mmm[bbb[i][j]]
			sss.each{|x|
				wk2 = x.distance_to(j,i)
				if wk < 0 then
					wk = wk2
				else
					wk = wk2 if wk > wk2
				end
			}
			mmm[bbb[i][j]] = wk
		end
	end
end
q = gets.chomp.to_i
t = gets.chomp

ret = 0
t.each_byte{|x|
	x = x.chr
	if mmm.key?(x.downcase) == false then
		ret = -1
		break
	end
	if x.upcase == x then
		x.downcase!
		if mmm[x] < 0 then
			ret = -1
			break
		end
		ret += 1 if xx < mmm[x]
	end
}

puts ret


def func
  n, m, x = gets.split.map(&:to_i)

  has_shift = false
  kb=[]
  n.times{
    l = gets.chomp
    kb << l
    has_shift |= (l =~ /S/)
  }
  alphabets = (kb * '').gsub('S', '')

  need_two = {}
  n.times{|y1|
    m.times{|x1|
      next if kb[y1][x1] != ?S
      n.times{|y2|
        m.times{|x2|
          c = kb[y2][x2]
          next if c == ?S

          dist2 = (y2-y1)**2 + (x2-x1)**2
          need_two[c] = [need_two[c] || 99999999, dist2].min
        }
      }
    }
  }

  need_two.each do |k, v|
    need_two[k] = v > x * x
  end
  #p need_two

  q = gets.to_i
  str = gets.chomp

  ok = true
  str.each_char do |c|
    if !alphabets.index(c.downcase)
      ok = false
      break
    end

    if c =~ /[A-Z]/ && !has_shift
      ok = false
      break
    end
  end
  if !ok
    return -1
  end

  cnt = 0
  str.each_char do |c|
    if c =~ /[a-z]/
      next
    end

    if need_two[c.downcase[0]]
      cnt += 1
    end
  end
  cnt
end

p func


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    gets; t = gets;

    t.each_char{|a|
        return -1 if a < 'a'
    } if !h['S']

    res = 0

    t.each_char{|a|
        if (t[i] < 'a') then
            t[i] += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
        else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << gets
    }

    (0...n).each{|x|
        (0...m).each{|y|

            h[s[x][y]] = true

            if (s[x][y] == 'S') then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
            end
        }
    }

    gets; t = gets; t.chop!

=begin
     if (t.length > 1) then
     puts t
     p h
     end
=end

    t.each_char{|a|
        return -1 if a < 'a'
    } if !h['S']

    res = 0

    t.each_char{|a|
        if (a < 'a') then
            a.upcase!
            return -1 if (!h[a])
            res += 1 if (!h_[a])
        else
            return -1 if (!h[a])
        end
    }

    return res
end

#$stdin = File.open("in.txt", "r")
puts solve


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    puts '?'

    q = readline; q = q.to_i;

    t = String.new(readline);

    puts t

    t.each{|a|
        return -1 if a < 'a'
    } if !h['S']

    puts "?"

    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
        else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    t.each{|a|
        return -1 if a < 'a'
    } if !h['S']

    puts "?"

    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
        else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    t.each{|a| return -1 if a < 'a'
    } if !h['S']

    res = 0
    (0...q).each{|i|
        if (t[i] < 'a') then
            t[i] += 32
            return -1 if (!h[t[i]])
            res += 1 if !h_[t[i]]
            else
            return -1 if (!h[t[i]])
        end
    }
    puts res
    return res
end

puts solve
return 0


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    puts '?'

    q = readline; q = q.to_i; t << readline;

    puts t

    t.each{|a|
        return -1 if a < 'a'
    } if !h['S']

    puts "?"

    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
        else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)


#$stdin = File.open("in.txt", "r")

def solve
    return '-1'
end

puts solve


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    t.each{|a|
        #if a < 'a' then
            #return -1;
            #        end
        return (-1) if a < 'a'
    } if !h['S']

    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    t.each{|a|
        if a < 'a' then
            return -1;
        end
        #return '-1' if a < 'a'
    } if !h['S']

    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
puts solve


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    res = 0
    (0...q).each{|i|
        if (t[i] < 97) then
            t[i] += 32
            return -1 if (!h[t[i]])
            res += 1 if !h_[t[i]]
            else
            return -1 if (!h[t[i]])
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
puts solve


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    gets; t = gets;

    if (t.length > 1) puts t

    t.each_char{|a|
        return -1 if a < 'a'
    } if !h['S']

    res = 0

    t.each_char{|a|
        if (t[i] < 'a') then
            t[i] += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
        else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    puts '?'
    q = readline; q = q.to_i; t = readline

    puts '?'

    puts t

    t.each{|a|
        return -1 if a < 'a'
    } if !h['S']

    puts '?'
    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
puts solve
return 0


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << gets
    }

    (0...n).each{|x|
        (0...m).each{|y|

            h[s[x][y]] = true

            if (s[x][y] == 'S') then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
            end
        }
    }

    gets; t = gets; t.chop!

    if (t.length > 1) then
        puts t
        p h
    end
=begin
    t.each_char{|a|
        return -1 if a < 'a'
    } if !h['S']
=end
    res = 0

    t.each_char{|a|
        if (a < 'a') then
            a += 32
            return -1 if (!h[a])
            res += 1 if (!h_[a])
        else
            return -1 if (!h[a])
        end
    }

    return res
end

#$stdin = File.open("in.txt", "r")
puts solve


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << gets
    }

    (0...n).each{|x|
        (0...m).each{|y|

            h[s[x][y].chr] = true

            if (s[x][y].chr == 'S') then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j].chr] = true
                        end
                    }
                }

                else
            end
        }
    }

    gets; t = gets; t.chop!

    t.each_char{|a|
        return -1 if a < 'a'
    } if !h['S']

    res = 0

    t.each_char{|a|
        if (a < 'a') then
            a.downcase!
            return -1 if (!h[a])
            res += 1 if (!h_[a])
            else
            return -1 if (!h[a])
        end
    }

    return res
end

#$stdin = File.open("in.txt", "r")
puts solve


#$stdin = File.open("in.txt", "r")

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    t.each{|a|
        if a < 'a' then
            puts -1
            return
        end
        #return (-1) if a < 'a'
    } if !h['S']

    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }
    return res


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << gets
    }

    (0...n).each{|x|
        (0...m).each{|y|

            h[s[x][y]] = true

            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
            end
        }
    }

    gets; t = gets;

    t.each_byte{|a|
        return -1 if a < 97
    } if !h[83]

    res = 0

    t.each_byte{|a|
        if (a < 97) then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }

    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    t.each{|a| return -1 if a < 'a'
    } if !h['S']

    res = 0
    (0...q).each{|i|
        if (t[i] < 'a') then
            t[i] += 32
            return -1 if (!h[t[i]])
            res += 1 if !h_[t[i]]
            else
            return -1 if (!h[t[i]])
        end
    }
    return res
end

puts solve
return 0


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    q = readline; q = q.to_i; t = readline

    t.each{|a|
        if a < 'a' then
            puts -1
            return
        end
        #return (-1) if a < 'a'
    } if !h['S']

    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
solve


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << gets
    }

    (0...n).each{|x|
        (0...m).each{|y|

            h[s[x][y]] = true

            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
            end
        }
    }

    gets; t = gets; t.chop!

    t.each_byte{|a|
        return -1 if a < 97
    } if !h[83]

    res = 0

    if (t.length > 1) then puts t end

    t.each_byte{|a|
        if (a < 97) then
            a += 32
            return -1 if (!h[a])
            res += 1 if (!h_[a])
            else
            return -1 if (!h[a])
        end
    }

    return res
end

#$stdin = File.open("in.txt", "r")
puts solve


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << readline
    }

    (0...n).each{|x|
        (0...m).each{|y|
            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
                h[s[x][y]] = true
            end
        }
    }

    puts '?'
    q = readline; q = q.to_i; t = readline

    puts '?'

    puts t

    t.each{|a|
        return '-1' if a < 'a'
    } if !h['S']

    puts '?'
    res = 0

    t.each{|a|
        if (a < 'a') then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }
    return res
end

#$stdin = File.open("in.txt", "r")
puts solve
return 0


def solve

    def sqr(x)
        return x * x
    end

    n , m , x = readline.split(' ')
    n = n.to_i; m = m.to_i; x = x.to_i; xx = sqr(x)

    s = Array.new; h = Hash.new(false); h_ = Hash.new(false)

    n.times {
        s << gets
    }

    (0...n).each{|x|
        (0...m).each{|y|

            h[s[x][y]] = true

            if (s[x][y] == 83) then
                (0...n).each{|i|
                    (0...m).each{|j|
                        if (sqr(i-x) + sqr(j-y) <= xx) then
                            h_[s[i][j]] = true
                        end
                    }
                }

                else
            end
        }
    }

    gets; t = gets; t.chop!

    t.each_byte{|a|
        return -1 if a < 97
    } if !h[83]

    res = 0

    t.each_byte{|a|
        if (a < 97) then
            a += 32
            return -1 if !h[a]
            res += 1 if !h_[a]
            else
            return -1 if !h[a]
        end
    }

    return res
end

#$stdin = File.open("in.txt", "r")
printf("%d", solve)