#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>

#define int long long
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
#define lc (x<<1)
#define rc (x<<1|1)
#define fan(x) (((x-1)^1)+1)
#define max Max
#define min Min
#define abs Abs

using namespace std;

inline int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
	return ans*f;
}

inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x/10) write(x/10);
	putchar((char)(x%10)+'0');
}

template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a>b?b:a;}
template<typename T,typename TT> inline T Max(T a,TT b){return a>b?a:b;}

const int N=3e5+5;
int n,a[N];

struct BIT
{
	int c[N];
	inline void add(int x,int v)
	{
		for(;x<=n;x+=lowbit(x))
			c[x]+=v;
	}
	inline int getsum(int x)
	{
		int res=0;
		for(;x;x-=lowbit(x))
			res+=c[x];
		return res;
	}
	inline int query(int l,int r)
	{
		return getsum(r)-getsum(l-1);
	}
}sum;

signed main()
{
	n=read();
	for(int i=1;i<=n;++i)
		a[i]=read();
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		ans+=sum.query(a[i]+2,n);
		sum.add(a[i]+1,1);
	}
	printf("%lld\n",ans);
	for(int i=1;i<=n-1;++i)
	{
		ans-=a[i];
		ans+=n-a[i]-1;
		printf("%lld\n",ans);
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
 
cs int G = 3;
cs int ff = 2e6 + 1;
cs int inf = 1e18 + 1;
cs int base = 2333;
cs int M = 1e9 + 7;

int ksm(int a, int b) { return (b % 2 == 1 ? a : 1) * (b ? ksm(a * a % M, b / 2) : 1) % M; }
int x, y, a[2333][2333], b[2333][3333], l[ff], r[ff], Ans, ss;
char s;
void init()
{
	cin >> x >> y;
	rep(i, 1, x)
		rep(j, 1, y)
			cin >> s, a[i][j] = (s != '#'), ss += a[i][j];
	rep(i, 1, x)
	{
		int las = 0, s = 0;
		rep(j, 1, y)
		{
			if(a[i][j]) b[i][j] += s, s ++;
			else s = 0;
			
		}
		s = 0;
		sep(j, y, 1)
		{
			if(a[i][j]) b[i][j] += s, s ++;
			else s = 0;
			
		}
	}
//	rep(i, 1, x) rep(j, 1, y) cout <<b[i][j] << " "; cout << "\n";
	rep(i, 1, y)
	{
		int las = 0, s = 0;
		rep(j, 1, x)
		{
		//	cout << j << " " << i << " " <<s << "\n";
			if(a[j][i]) b[j][i] += s, s ++;
			else s = 0;
		//	
		}
		s = 0;
		sep(j, x, 1)
		{
			if(a[j][i]) b[j][i] += s, s ++;
			else s = 0;
		//	cout <<b[j][i] << "\n";
		}
	}
	rep(i, 1, x)
		rep(j, 1, y)
		{
			if(!a[i][j]) continue;
		//	cout <<b[i][j] << " ";
			int sum = b[i][j] + a[i][j];
		//	cout << sum <<"\n";
			Ans = Ans + ksm(2, ss) - ksm(2, ss - sum);
			Ans = (Ans % M + M) % M;
		}
	cout << Ans;
} 
signed main()
{
//	freopen("1.out", "w", stdout);
	int Ts = 1;
//	cin >> Ts;
	while(Ts--)
		init();
}
