#include <bits/stdc++.h>
using namespace std;
int read() {
  int f = 1, x = 0;
  char c = (int)getchar();
  while (c < '0' || '9' < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f * x;
}
const int MAXN = 1000000;
const int INF = 0x3f3f3f3f;
const int Mod = (int)(1e9 + 7);
int cnt[MAXN + 5], a[MAXN + 5];
int Pow(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % Mod;
    x = 1ll * x * x % Mod, y >>= 1;
  }
  return ret;
}
int main() {
  int n = read(), sum = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] != -1) cnt[a[i]]++;
  }
  for (int i = 1; i <= n; i++)
    if (cnt[i]) sum = (sum + Pow(2, cnt[i]) - 1) % Mod;
  printf("%d\n", (Pow(2, n - 1) - 1 - sum + Mod) % Mod);
  return 0;
}
