#include <bits/stdc++.h>
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const double pi = acos(-1);

using namespace std;
inline ll read(){
    ll x = 0, f = 1;char ch = getchar();
    while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
    return x * f;
}

ll ans;
char ch[2005][2005];
int pre[2005][2005][4], sum;
int n, m, bit[4000005];
int main(){
	int i, j;
	n = read(), m = read();
	bit[0] = 1;
	for(i = 1;i <= n * m;i++) bit[i] = bit[i - 1] * 2 % mod;
	for(i = 1;i <= n;i++) scanf("%s", ch[i] + 1);
	for(i = 1;i <= n;i++){
		int now = 0;
		for(j = 1;j <= m;j++){
			if(ch[i][j] == '#') now = 0;
			else now++, sum++;
			pre[i][j][0] = now;
		}
		now = 0;
		for(j = m;j >= 1;j--){
			if(ch[i][j] == '#') now = 0;
			else now++, sum++;
			pre[i][j][1] = now;
		}
	}
	for(i = 1;i <= m;i++){
		int now = 0;
		for(j = 1;j <= n;j++){
			if(ch[j][i] == '#') now = 0;
			else now++, sum++;
			pre[j][i][2] = now;
		}
		now = 0;
		for(j = n;j >= 1;j--){
			if(ch[j][i] == '#') now = 0;
			else now++, sum++;
			pre[j][i][3] = now;
		}
	}
	sum/=4;
	int ans = 0;
	for(i = 1;i <= n;i++){
		for(j = 1;j <= m;j++){
			if(ch[i][j] == '#') continue;
			int now = 0;
			for(int k = 0;k <= 3;k++) now += pre[i][j][k];
			now -= 3;
			ans = (ans + 1ll * (bit[now] - 1) * (bit[sum - now]) % mod) % mod;
		}
	}
	printf("%d\n", ans);
}
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; i++){
    cin >> T[i];
  }
  int S = 0;
  for (int i = 0; i < N; i++){
    S += T[i];
  }
  vector<vector<bool>> dp(N + 1, vector<bool>(S + 1, false));
  dp[0][0] = true;
  for (int i = 0; i < N; i++){
    for (int j = 0; j <= S; j++){
      if (dp[i][j]){
        dp[i + 1][j] = true;
        dp[i + 1][j + T[i]] = true;
      }
    }
  }
  int ans = S;
  for (int i = 0; i <= S; i++){
    if (dp[N][i]){
      ans = min(ans, max(i, S - i));
    }
  }
  cout << ans << endl;
}