import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n = int(input()) S = [list(input().rstrip()) for _ in range(n)] blank = "." * (n - 1) def rot(A): n, m = len(A), len(A[0]) res = [[0] * n for _ in range(m)] for i in range(n): for j in range(m): res[j][n - i - 1] = A[i][j] return res def count(): res = 0 for i in range(1, n - 1): res += int("".join(S[i][:n-1]) == blank) a0 = int("".join(S[0][:n-1]) == blank) a1 = int("".join(S[0][1:]) == blank) b0 = int("".join(S[-1][:n-1]) == blank) b1 = int("".join(S[-1][1:]) == blank) c0 = int(all(S[i][-1] == "." for i in range(n - 1))) c1 = int(all(S[i][-1] == "." for i in range(1, n))) tmp = a0 + b0 + max(c0, c1) tmp = max(tmp, a0 + b1 + c0) tmp = max(tmp, a1 + b0 + c1) tmp = max(tmp, a1 + b1) return res + tmp ans = 0 for _ in range(4): ans = max(ans, count()) S = rot(S) ng = 0 for i in range(n): ng |= S[0][i] == "#" ng |= S[i][0] == "#" ng |= S[-1][i] == "#" ng |= S[i][-1] == "#" if not ng: ans = max(ans, 4) print(ans)