#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;

#define ull unsigned long long
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
   ifstream fin("input.txt");
   ofstream fout("output.txt");
#define cin fin
#define cout fout
 */
char graph[1001][1001];
bool visited[1001][1001];
int maxi;
int k;

void solve(){
	rep(i,k){
		rep(j,k){
			if(graph[i][j] == '.' && !visited[i][j]){
				int tmp = 1;
				bool flag = true;
				queue<int> type;
				queue<pair<int,int> > nodes;
				type.push(2);
				nodes.push(make_pair(i,j));
				while(flag && nodes.size()>0){
					int t = 2*(tmp-1)+1;
					if(nodes.size() < t)break;
					vector<pair<int,int> > vis;
					rep(w,t){
						pair<int,int> nx = nodes.front();
						vis.push_back(nodes.front());
						int tt = type.front();
						nodes.pop();type.pop();
						if(tt == 2){
							if(nx.first + 0 < k && nx.second + 1 < k){
								if(graph[nx.first][nx.second+1] == '.'){
									nodes.push(make_pair(nx.first,nx.second+1));
									type.push(0);
								}else{flag = false;}
							} 
							if(nx.first + 1 < k && nx.second + 1 < k){
								if(graph[nx.first+1][nx.second+1] == '.'){
									nodes.push(make_pair(nx.first+1,nx.second+1));
									type.push(2);
								}else{flag = false;}
							}
							if(nx.first + 1 < k && nx.second + 0 < k){
								if(graph[nx.first+1][nx.second] == '.'){
									nodes.push(make_pair(nx.first+1,nx.second));
									type.push(1);
								}else{flag = false;}
							}
						}else if(tt == 1){
							if(nx.first + 1 < k && nx.second + 0 < k){
								if(graph[nx.first+1][nx.second] == '.'){
									nodes.push(make_pair(nx.first+1,nx.second));
									type.push(1);
								}else{flag = false;}
							}	
						}else{
							if(nx.first + 0 < k && nx.second + 1 < k){
								if(graph[nx.first][nx.second+1] == '.'){
									nodes.push(make_pair(nx.first,nx.second+1));
									type.push(0);
								}else{flag = false;}
							}
						}
						//	cout<<nx.first<<"$"<<nx.second<<endl;

					}
					if(flag){
						rep(i,vis.size()){
							visited[vis[i].first][vis[i].second] = true;
						}
						if(nodes.size()>0)tmp++;	
					}
				}


				maxi = max(tmp,maxi);
			}
		}
	}
}

int main(){
	while(scanf("%d",&k),k){
		memset(graph,'*',sizeof(graph));
		memset(visited,0,sizeof(visited));
		maxi = -1;
		rep(i,k){
			scanf("%s",&graph[i]);
		}
		solve();
		printf("%d\n",maxi);
	}
	return 0;
}