#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long w = 0, f = 1;
  char c = ' ';
  while (c < '0' || c > '9') c = getchar(), f = c == '-' ? -1 : f;
  while (c >= '0' && c <= '9') w = w * 10 + c - 48, c = getchar();
  return w * f;
}
const long long mod = 1e9 + 7;
long long pown(long long x, long long y) {
  long long res = 1, ans = x;
  while (y) {
    if (y & 1) res = res * ans % mod;
    ans = ans * ans % mod;
    y >>= 1;
  }
  return res;
}
long long n, a[505], siz[505], ans;
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] != -1) siz[a[i]]++;
  }
  ans = pown(2, n - 1) - 1;
  for (long long i = 1; i <= n; i++)
    if (siz[i]) ans = (ans - pown(2, siz[i]) + 1) % mod;
  printf("%lld", (ans + mod) % mod);
  return 0;
}
