#include <bits/stdc++.h>
const int MOD = int(1E9) + 7;
const int MAXN = 100000;
int pw[MAXN + 5], cnt[MAXN + 5];
void init() {
  pw[0] = 1;
  for (int i = 1; i <= MAXN; i++) pw[i] = 2LL * pw[i - 1] % MOD;
}
int main() {
  init();
  int n, x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x != -1) cnt[x]++;
  }
  int ans = pw[n - 1] - 1;
  for (int i = 1; i <= n; i++) ans = (ans - 1LL * (pw[cnt[i]] - 1) % MOD) % MOD;
  printf("%d\n", (ans + MOD) % MOD);
}
