#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, n) for(decltype(n) i = (a), i##__ = (n); i <= i##__; i++)
#define REP(i, n) FOR(i, 0, (n)-1)
#define FORD(i, a, n) for(decltype(a) i = (a), i##__ = (n); i >= i##__; i--)
#define REPD(i, n) FORD(i, (n)-1, 0)
#define V vector
#define ST first
#define ND second
#define EB emplace_back
#define RS resize
#define SZ(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define OS ostream

template<class A, class B> OS& operator<<(OS &os, pair<A, B> p) {
	return os << "(" << p.ST << ", " << p.ND << ")";
}
template<class A> OS& operator<<(OS &os, V<A> v) {
	os << "{ ";
	for(auto e : v) os << e << " ";
	return os << "}";
}
template<class A> OS& operator<<(OS &os, V<V<A>> v) {
	os << "[\n";
	for(auto e : v) os << "  " << e << "\n";
	return os << "]";
}

#ifdef DEBUG
# define D(a...) a
# define _D(a...)
#else
# define D(a...)
# define _D(a...) a
#endif
# define I(a...) #a << ": " << a << "\n"
# define J(a...) #a << ": " << a << "  "

using VI   = V<int>;
using VVI  = V<VI>;
using VB   = V<bool>;
using VVB  = V<VB>;
using II   = pair<int, int>;
using VII  = V<II>;
using L    = long long;
using VL   = V<L>;
using VVL  = V<VL>;

int n;
V<V<char>> in;
constexpr char sun = '*';
constexpr char house = '^';
constexpr char chupacabra = '!';
constexpr char lefty = '/';
constexpr char righty = '\\';
constexpr char bird = 'v';
constexpr char drake = 'D';
constexpr char grill = 'G';
constexpr char space = ' ';


inline bool is_bird(int i, int j) {
	return in[i][j] == bird or in[i][j] == drake;
}
inline bool is_animal(int i, int j) {
	return is_bird(i, j) or in[i][j] == chupacabra;
}
inline bool is_good(int i, int j) {
	return i >= 0 and i < n and j >= 0 and j < n;
}

int char_value(char x) {
	if(x == sun) return 0;
	if(x == house) return 1;
	if(x == chupacabra) return 2;
	if(x == lefty) return 3;
	if(x == righty) return 4;
	if(x == bird) return 5;
	if(x == drake) return 6;
	if(x == grill) return 7;
	if(x == space) return 8;
	return 9;
}

int value_sun(int i, int j) {
	if(in[i][j] != sun and in[i][j] != space) {
		FOR(new_j, j + 1, n - 1) {
			if(in[i][new_j] == sun)
				return 100;
			if(in[i][new_j] != space)
				break;
		}
		FORD(new_j, j - 1, 0) {
			if(in[i][new_j] == sun)
				return 100;
			if(in[i][new_j] != space)
				break;
		}
		FOR(new_i, i + 1, n - 1) {
			if(in[new_i][j] == sun)
				return 100;
			if(in[new_i][j] != space)
				break;
		}
		FORD(new_i, i - 1, 0) {
			if(in[new_i][j] == sun)
				return 100;
			if(in[new_i][j] != space)
				break;
		}
		for(int new_i = i + 1, new_j = j + 1; new_i < n and new_j < n; new_i++, new_j++) {
			if(in[new_i][new_j] == sun)
				return 100;
			if(in[new_i][new_j] != space)
				break;
		}
		for(int new_i = i - 1, new_j = j + 1; new_i >= 0 and new_j < n; new_i--, new_j++) {
			if(in[new_i][new_j] == sun)
				return 100;
			if(in[new_i][new_j] != space)
				break;
		}
		for(int new_i = i + 1, new_j = j - 1; new_i < n and new_j >= 0; new_i++, new_j--) {
			if(in[new_i][new_j] == sun)
				return 100;
			if(in[new_i][new_j] != space)
				break;
		}
		for(int new_i = i - 1, new_j = j - 1; new_i >= 0 and new_j >= 0; new_i--, new_j--) {
			if(in[new_i][new_j] == sun)
				return 100;
			if(in[new_i][new_j] != space)
				break;
		}
	}
	D(cerr << II(i, j) << " not iluminated\n");
	return 0;
}

int value_chupacabra(int i, int j) {
	if(is_bird(i, j)) {
		for(II delta: {II(2, 1), II(1, 2), II(-2, 1), II(-1, 2), II(2, -1), II(1, -2), II(-2, -1), II(-1, -2)})
			if(is_good(i + delta.ST, j + delta.ND) and in[i + delta.ST][j + delta.ND] == chupacabra)
				return 200;
	}
	return 0;
}

VI repr;
int fajnd(int x) {
	return repr[x] == x ? x : repr[x] = fajnd(repr[x]);
}
void junion(int x, int y) {
	repr[fajnd(x)] = fajnd(y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n;
	in.RS(n, V<char>(n));
	string enter; getline(cin, enter);
	REP(i, n) {
		string s; getline(cin, s);
		REP(j, n)
			in[i][j] = s[j];
	}	

	L value = 0;
	// SUNS
	L value_suns = 0;
	REP(i, n) REP(j, n) {
		value_suns += value_sun(i, j);
	}
	D(cerr << I(value_suns));

	// BIGGEST BIRD
	repr.RS(n * n); iota(ALL(repr), 0);
	REP(i, n) REP(j, n - 1)	{
		if(is_bird(i, j) and is_bird(i, j + 1))
			junion(i * n + j, i * n + j + 1);
	}
	REP(i, n - 1) REP(j, n) {
		if(is_bird(i, j) and is_bird(i + 1, j))
			junion(i * n + j, (i + 1) * n + j);
	}
	REP(i, n) REP(j, n)
		repr[i * n + j] = fajnd(i * n + j);
	VI biggest(n * n, 0);
	REP(i, n) {
		int current = 0;
		REP(j, n) {
			if(j == 0 or repr[i * n + j] != repr[i * n + j - 1])
				current = 0;
			current++;
			if(is_bird(i, j))
				biggest[repr[i * n + j]] = max(biggest[repr[i * n + j]], current);
		}
	}
	L biggest_bird_value = 0;
	for(int b : biggest) {
		//if(b)
		//	D(cerr << "mam " << b << "\n");
		biggest_bird_value += 500 * b;
	}
	D(cerr << I(biggest_bird_value));

	// FLOCK PERIMITER
	L value_perim = 0;
	REP(i, n - 1) REP(j, n) 
		if(is_bird(i, j) xor is_bird(i + 1, j))
			value_perim += 60;
	REP(i, n) REP(j, n - 1)
		if(is_bird(i, j) xor is_bird(i, j + 1))
			value_perim += 60;
	REP(k, n) {
		if(is_bird(k, 0))
			value_perim += 60;
		if(is_bird(k, n - 1))
			value_perim += 60;
		if(is_bird(0, k))
			value_perim += 60;
		if(is_bird(n - 1, k))
			value_perim += 60;
	}
	D(cerr << I(value_perim));

	// HOUSE
	L value_house = 0;
	REP(i, n) REP(j, n) {
		if(in[i][j] == house)
			for(int new_i = i - 1; new_i >= 0; new_i--) {
				if(in[new_i][j] == space)
					value_house += 15;
				else
					break;
			}
	}
	D(cerr << I(value_house));

	// UNIQUE
	VL pow_ten = {1};
	REP(i, 10)
		pow_ten.EB(pow_ten.back() * 10);
	set<L> hashes;
	REP(i, n - 2) REP(j, n - 2) {
		L hash = 0;
		REP(di, 3) REP(dj, 3) 
			hash += pow_ten[di * 3 + dj] * char_value(in[i + di][j + dj]);
		hashes.insert(hash);
	}
	L value_unique = SZ(hashes);
	/*sort(ALL(hashes));
	REP(i, SZ(hashes))
		if((i == 0 or hashes[i] != hashes[i - 1]) and (i == SZ(hashes) - 1 or hashes[i] != hashes[i + 1]))
			value_unique++;*/
	D(cerr << I(value_unique));
	
	// ANIMALS I
	L value_animals_i = 0;
	REP(i, n - 1) REP(j, n) {
		if((is_animal(i, j) and in[i + 1][j] == space) or (in[i][j] == space and is_animal(i + 1, j)))
		value_animals_i += 15;
	}	
	REP(i, n) REP(j, n - 1) {
		if((is_animal(i, j) and in[i][j + 1] == space) or (in[i][j] == space and is_animal(i, j + 1)))
		value_animals_i += 15;
	}
	D(cerr << I(value_animals_i));


	// FREEDOM
	VVB is_free(n, VB(n, false));
	deque<II> free_cells;
	REP(j, n) {
		if(in[0][j] == space)
			free_cells.EB(0, j), is_free[0][j] = true;
		if(in[n - 1][j] == space)
			free_cells.EB(n - 1, j), is_free[n - 1][j] = true;
		if(in[j][0] == space)
			free_cells.EB(j, 0), is_free[j][0] = true;
		if(in[j][n - 1] == space)
			free_cells.EB(j, n - 1), is_free[j][n - 1] = true;
	}
	while(SZ(free_cells)) { 
		II cell = free_cells.front();
		free_cells.pop_front();
		for(II delta : {II(1, 0), II(-1, 0), II(0, 1), II(0, -1)}) {
			if(is_good(cell.ST + delta.ST, cell.ND + delta.ND)) {
				int i = cell.ST + delta.ST, j = cell.ND + delta.ND;
				if(in[i][j] == space and not is_free[i][j])
					is_free[i][j] = true, free_cells.EB(i, j);
			}
		}
	}
	L value_freedom = 0;
	REP(i, n) REP(j, n) if(in[i][j] != space) {
		for(II delta: {II(1, 0), II(-1, 0), II(0, 1), II(0, -1)})
			if(not is_good(i + delta.ST, j + delta.ND) or is_free[i + delta.ST][j + delta.ND]) {
				value_freedom += 7;
				break;
			}
	}
	D(cerr << I(value_freedom));

	// CHUPACABRA
	L value_ch = 0;
	REP(i, n) REP(j, n) {
		value_ch += value_chupacabra(i, j);	
	}
	D(cerr << I(value_ch));

	// PEAKS
	L value_peaks = 0;
	VII peaks;
	REP(i, n) REP(j, n - 1)
		if(in[i][j] == lefty and in[i][j + 1] == righty)
			peaks.EB(i, j);
	D(cerr << I(peaks));
	for(II &p : peaks) {
		L ans = 0;
		for(II &q : peaks)
			ans = max<L>(ans, abs(p.ST - q.ST) + abs(p.ND - q.ND));
		value_peaks += 50 * ans;
		D(cerr << J(p) << " - I add " << ans << "\n");
	}
	D(cerr << I(value_peaks));

	// DRAKE/GRILL
	L value_grill = 0;
	REP(i, n) REP(j, n) {
		if(in[i][j] == drake) {
			for(II delta : {II(1, 0), II(-1, 0), II(0, 1), II(0, -1)})
				if(is_good(i + delta.ST, j + delta.ND) and in[i + delta.ST][j + delta.ND] == grill) {
					value_grill += 500;
					break;
				}
		}
	}
	D(cerr << I(value_grill));

	// FREQUENCY & EMPTY & ANIMALS 2 & HOUSES AND GRILLS
	L value_freq = 0;
	VI freq(9, 0);
	REP(i, n) REP(j, n)
		freq[char_value(in[i][j])]++;
	L value_empty = freq[8];
	L value_animals_ii = L(freq[2]) * freq[5] * freq[6];
	L value_houses_and_grills =  3 * min(freq[1], freq[7]);
	freq.pop_back();
	sort(ALL(freq));
	//D(cerr << I(freq));
	int min = 10000000;
	for(int f : freq)
		if(f > 0 and f < min)
			min = f;
	for(int f : freq)
		if(f == min)
			value_freq += f * 10;
	D(cerr << I(value_freq) << I(value_empty) << I(value_animals_ii) << I(value_houses_and_grills));

	// HOUSE VIEW DOWN
	/* L value_house_down = 0;
	REP(i, n) REP(j, n) {
		if(in[i][j] == house)
			for(int new_i = i + 1; new_i < n; new_i++) {
				if(in[new_i][j] == space)
					value_house_down += 5;
				else
					break;
			}
	}
	D(cerr << I(value_house_down)); */

	// GRILL/DRAKE	
	L value_drake = 0;
	REP(i, n) REP(j, n) {
		if(in[i][j] == grill) {
			for(II delta : {II(1, 0), II(-1, 0), II(0, 1), II(0, -1)})
				if(is_good(i + delta.ST, j + delta.ND) and in[i + delta.ST][j + delta.ND] == drake) {
					value_drake += 50;
					break;
				}
		}
	}
	D(cerr << I(value_drake));

	cout << value_suns + 
			biggest_bird_value + 
			value_perim + 
			value_house + 
			value_unique + 
			value_animals_i + 
			value_freedom + 
			value_ch + 
			value_peaks + 
			value_drake + 
			value_freq + 
			value_empty + 
			value_animals_ii + 
			value_grill + 
			value_houses_and_grills << "\n";
}

