#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
inline void print(long long x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x >= 10) print(x / 10);
  putchar((x % 10) | 48);
}
long long n;
vector<long long> vec[510];
const long long mod = 1e9 + 7;
long long a[510];
long long s[510];
long long sum;
signed main() {
  n = read();
  s[0] = 1;
  for (long long i = 1; i <= n; ++i) s[i] = (s[i - 1] << 1) % mod;
  for (long long i = 1; i <= n; ++i) {
    a[i] = read();
    if (a[i] > 0) vec[a[i]].push_back(i);
  }
  for (long long i = 1; i <= n; ++i) {
    if (a[i] == -1) {
      (sum += s[vec[i].size()] - 1) %= mod;
    }
  }
  printf("%d\n", (s[n - 1] - 1 - sum + mod) % mod);
  return 0;
}
