//采用暴力的方法做的,可惜时间不够了,给的例子通过了,不知道还有没有什么问题。仅供参考
#define _CRT_SECURE_NO_WARNINGS
// #define STDIN_OUT
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<map>
#include<cmath>
#include<deque>
#include<unordered_map>
using namespace std;
class Solution {
public:
	int lcs(vector<int> str1,vector<int> str2)
	{
		 int len1 = str1.size();
	     int len2 = str2.size();
	     vector<vector<int>> a(len1+1,vector<int>(len2+1,0));
		int n_max = 0;
		for(int i = 0; i < len1; i++) a[i][0] = 0;
		for(int j = 0; j < len2; j++) a[0][j] = 0;
		for(int i = 1; i <= len1; i++){
			for(int j = 1; j <= len2; j++){
				if(str1[i-1] == str2[j-1])
					a[i][j] = a[i-1][j-1] + 1;
				else{
					a[i][j] = max(a[i-1][j],a[i][j-1]);
				}
				n_max = max(n_max,a[i][j]);
			}
		}
		return n_max;
	}
	void dfs(int n, int k, int start, int cur,vector<int> path, vector<vector<int>> &res){
		if(cur == k){
			res.push_back(path);
			return;
		}
		if(cur < k)
			for(int i = start; i <= n; i++){
				path.push_back(i);
				dfs(n,k,start,cur+1,path,res);
				path.pop_back();
			}
	}
    vector<vector<int>> combine(int start,int end, int k) {//所有的排列组合
        vector<vector<int>> res;
        vector<int> path;
        dfs(end,k,start,0,path,res);
        return res;
    }
};
int main()
{
#ifdef STDIN_OUT
    freopen("D:\\input.txt", "r", stdin);
    freopen("D:\\output.txt", "w", stdout);
#endif
    int m,n,L,R,k;
    vector<int> str1;
 	Solution s;
    cin>>n>>m;
    cin>>k;
    cin>>L>>R;
    for(int i = 0; i < n;i++)
    {
    	int val;
    	cin>>val;
    	str1.push_back(val);
    }
    vector<vector<int>> res = s.combine(L,R,m);
    int count = 0;
    for(auto re : res){
    	int LCIS = s.lcs(str1,re);
    	if(LCIS >= k)
    		count = (count + 1) % 10007;
    }
    cout<<count<<endl;
#ifdef STDIN_OUT
    fclose(stdin);
    fclose(stdout);
#endif
    return 0;
}