#include<cstdio>
#include<iostream>
using namespace std;

#define N 2005
#define ll long long 
const int mod=1e9+7;
int n,m;
string s;
ll sum1[N][N],sum2[N][N],sum3[N][N];
int dp[N][N],map[N][N];
int main()
{
	scanf("%d%d\n",&n,&m);
	for (int i=1 ; i<=n ; i++){
		cin>>s;
		for (int j=1 ; j<=m ; j++)
		    map[i][j]=s[j-1]=='.' ?1:0;
	}
	dp[1][1]=1;
	for (int i=1 ; i<=n ; i++){
	    for (int j=1 ; j<=m ; j++){
	    	if (i==1 && j==1) continue;
	    	if (map[i][j]==0) dp[i][j]=0;
	    	else{
	    	    sum1[i][j]=(sum1[i][j-1]+dp[i][j-1])%mod;
	    	    sum2[i][j]=(sum2[i-1][j]+dp[i-1][j])%mod;
	    	    sum3[i][j]=(sum3[i-1][j-1]+dp[i-1][j-1])%mod;
	    	    dp[i][j]=(sum1[i][j]+sum2[i][j]+sum3[i][j])%mod;
	        }
		}
	}
	printf("%d\n",dp[n][m]%mod);
	return 0;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++ i)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;

int N;
LL a[3005], dp[3005], dp2[3005];
LL sum[3005];

int main()
{
    scanf("%d", &N);
    rep1(i, N) scanf("%lld", &a[i]);
    rep1(i, N) a[i] += a[i - 1];

    dp2[0] = 1;
    LL ret = 0;
    rep1(k, N) {
        rep(i, k) sum[i] = 0;
        rep1(i, N) {
            sum[a[i - 1] % k] += dp2[i - 1];
            if (sum[a[i - 1] % k] >= MOD) sum[a[i - 1] % k] -= MOD;
            dp[i] = sum[a[i] % k];
        }
        ret += dp[N];
        if (ret >= MOD) ret -= MOD;
        rep(i, N + 1) dp2[i] = dp[i];
    }


    printf("%lld\n", ret);

    return 0;
}