#include<iostream>
#include<vector>
#include<queue>

using namespace std;

struct pos{
    int x;
    int y;
};
pos dir[] = {
    {1, 0},
    {-1, 0},
    {0, 1},
    {0, -1}
};

int main(){
    int H, W;
    int depth_max = 0;
    vector<vector<int>> depth;
    queue<pos> dest;
    cin >> H >> W;
    depth.resize(H, vector<int>(W, -1));
    for (int i = 0; i < H; i++){
        string str;
        cin >> str;
        for (int j = 0; j < W; j++){
            char c = str[j];
            if(c == '#'){
                dest.push({i, j});
                depth[i][j] = 0;
            }
        }
    }

    while(dest.size() != 0){
        pos now = dest.front();
        dest.pop();
        for (int i = 0; i < 4; i++){
            pos next = {now.x + dir[i].x, now.y + dir[i].y};
            if(next.x < 0 || H <= next.x || next.y < 0 || W <= next.y){
                continue;
            }
            if(depth[next.x][next.y] != -1){
                if(depth[next.x][next.y] > depth[now.x][now.y] + 1){
                    depth[next.x][next.y] = depth[now.x][now.y] + 1;
                    dest.push(next);
                }
                continue;
            }
            depth[next.x][next.y] = depth[now.x][now.y] + 1;
            dest.push(next);
        }
    }

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if(depth[i][j] > depth_max){
                depth_max = depth[i][j];
            }
        }
    }
    cout << depth_max << endl;
}
//https://codeforces.com/blog/entry/64250?#comment-576206

#include<bits/stdc++.h>
#define ll double

ll dp[301][301][301];
ll solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;
 
    if(dp[one][two][three] > 0)
        return dp[one][two][three];
 
    int remaining = one + two + three;
    ll exp_val = n + one * solve(one - 1, two, three, n) 
                   + two * solve(one + 1,two - 1, three, n) 
                   + three * solve(one, two + 1, three - 1, n);
 
    return dp[one][two][three] = exp_val / remaining;
}
 
int main()
{
    using namespace std;
    int n;
   
    cin >> n;
  
    int one = 0, two = 0, three = 0;

    for(int i = 0; i < n; i++) {
      int x;
      cin >> x;
      if(x == 1) one++;
      else if(x == 2) two++;
      else three++;
    }

    memset(dp, -1, sizeof(dp));
   
    cout << fixed << setprecision(9) << solve(one, two, three, n);
    
    return 0;
}
