#include using namespace std; int N; vector> ok; int yoko1(const int i) { auto copy = ok; for (int j = 0; j < N - 1; j++) { if (copy[i][j]) { copy[i][j] = false; } else { return 0; } } int ans = 1; for (int j = 0; j < N; j++) { bool f = true; for (int i = 1; i < N - 1; i++) { if (not copy[i][j]) { f = false; break; } } if (f and (copy[0][j] or copy[N - 1][j])) { ans++; } } return ans; } int yoko2(const int i) { auto copy = ok; for (int j = 1; j < N; j++) { if (copy[i][j]) { copy[i][j] = false; } else { return 0; } } int ans = 1; for (int j = 0; j < N; j++) { bool f = true; for (int i = 1; i < N - 1; i++) { if (not copy[i][j]) { f = false; break; } } if (f and (copy[0][j] or copy[N - 1][j])) { ans++; } } return ans; } int tate1(const int j) { auto copy = ok; for (int i = 0; i < N - 1; i++) { if (copy[i][j]) { copy[i][j] = false; } else { return 0; } } int ans = 1; for (int i = 0; i < N; i++) { bool f = true; for (int j = 1; j < N - 1; j++) { if (not copy[i][j]) { f = false; break; } } if (f and (copy[i][0] or copy[i][N - 1])) { ans++; } } return ans; } int tate2(const int j) { auto copy = ok; for (int i = 1; i < N; i++) { if (copy[i][j]) { copy[i][j] = false; } else { return 0; } } int ans = 1; for (int i = 0; i < N; i++) { bool f = true; for (int j = 1; j < N - 1; j++) { if (not copy[i][j]) { f = false; break; } } if (f and (copy[i][0] or copy[i][N - 1])) { ans++; } } return ans; } int YOKO1() { int ans = 0; for (int j = 0; j < N; j++) { bool f = true; for (int i = 1; i < N - 1; i++) { if (not ok[i][j]) { f = false; break; } } if (f and (ok[0][j] or ok[N - 1][j])) { ans++; } } return ans; } int YOKO2() { int ans = 0; for (int j = 0; j < N; j++) { bool f = true; for (int i = 1; i < N - 1; i++) { if (not ok[i][j]) { f = false; break; } } if (f and (ok[0][j] or ok[N - 1][j])) { ans++; } } return ans; } int TATE1() { int ans = 0; for (int i = 0; i < N; i++) { bool f = true; for (int j = 1; j < N - 1; j++) { if (not ok[i][j]) { f = false; break; } } if (f and (ok[i][0] or ok[i][N - 1])) { ans++; } } return ans; } int TATE2() { int ans = 0; for (int i = 0; i < N; i++) { bool f = true; for (int j = 1; j < N - 1; j++) { if (not ok[i][j]) { f = false; break; } } if (f and (ok[i][0] or ok[i][N - 1])) { ans++; } } return ans; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; ok.resize(N, vector(N)); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { char c; cin >> c; ok[i][j] = c == '.'; } } bool spe = true; for (int i = 0; i < N; i++) { if (not ok[i][0]) { spe = false; break; } if (not ok[i][N - 1]) { spe = false; break; } if (not ok[0][i]) { spe = false; break; } if (not ok[N - 1][i]) { spe = false; break; } } int ans = max({TATE1(), TATE2(), YOKO1(), YOKO2()}); if (spe) { ans = max(ans, 4); } for (int i = 0; i < N; i++) { ans = max({ans, tate1(i), tate2(i), yoko1(i), yoko2(i)}); } cout << ans << endl; return 0; }