n = int(raw_input()); gl = raw_input().split(’ ‘); a = []; a.append(0); s = 0; iz = 0; for i in range(0, n): a.append(int(gl[i]) - 1); s = s + a[i + 1]; if (a[i + 1] < 0): iz = 1; if (n == 1): if (a[1] == -1): print 1; else: print 0; elif (s != n - 2 or iz): print 0; else: fac = []; fac.append(1); for i in range(1, n + 1): fac.append(fac[i - 1] * i); ans = fac[n - 2]; for i in range(1, n + 1): if (a[i] > 0): ans = ans / fac[a[i]]; if (ans > 1e17): ans = 0; print ans;