Snackdown Pre elim:: Arranging the inventory question

Can anyone please tell me the border case for which my program is giving wrong answer. It would be very helpful. Below is my code.
Thanks.

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
string s;
cin>>s;
long long int i=0;int flag=0;long long int ctr=0,hashes=0,hashes2=0;
while(i<s.length() && s.at(i)==’#’)
{hashes++;i++;}

    while(i<s.length())
    	{char c=s.at(i);hashes2=0;
         if(c=='.')
           	while(i<s.length()&& s.at(i)=='.'){i++;}
           if(i>=s.length())
           	break;
         c=s.at(i);  
         if(c=='#')
         	{long long int ctr2=0,ctr3=0;long long int x=i-hashes;//cout<<x<<"x"<<endl;

         		while(i<s.length() && s.at(i)=='#')
                 {ctr2++;i++;hashes++;}
           //  cout<<ctr2<<"ctr2"<<endl;
                while(i<s.length() && s.at(i)=='.')
                	{ctr3++;i++;}
             //  cout<<ctr3<<"ctr3"<<endl;
                if(ctr2==1 && ctr3==1);
                else
                	if(ctr2>ctr3)
                	{flag=1;}
                ctr=ctr+x*(ctr2)+(2*(ctr2-1)*(ctr2))/2;
               }

            if(flag==1)
            	break;
    	}
    	 if(flag==1)
    	 	cout<<"-1"<<endl;
    	 else
    	 	cout<<ctr<<endl;}}
//