#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
struct mint {
  int val = 0;
  mint() {}
  mint(int a) : val(a) {
    while (val < 0) {
      val += M;
    }
    while (val >= M) {
      val -= M;
    }
  }
  mint(long long a) : val(a % M) {
    if (val < 0) {
      val += M;
    }
  }
  mint operator+=(mint oth) {
    val += oth.val;
    val -= (val >= M) ? M : 0;
    return *this;
  }
  mint operator-=(mint oth) {
    val -= oth.val;
    val += (val < 0) ? M : 0;
    return *this;
  }
  mint operator*=(mint oth) {
    val = 1LL * val * oth.val % M;
    return *this;
  }
  void operator++() {
    ++val;
    if (val == M) {
      val = 0;
    }
  }
  void operator--() {
    --val;
    if (val == -1) {
      val = M - 1;
    }
  }
  mint operator-() {
    mint res;
    res.val = (val == 0) ? 0 : M - val;
    return res;
  }
  friend mint operator+(mint a, mint b) { return mint(a) += b; }
  friend mint operator-(mint a, mint b) { return mint(a) -= b; }
  friend mint operator*(mint a, mint b) { return mint(a) *= b; }
  friend bool operator==(mint a, mint b) { return a.val == b.val; }
  friend bool operator!=(mint a, mint b) { return a.val != b.val; }
  friend ostream& operator<<(ostream& out, mint a) {
    out << a.val;
    return out;
  }
  friend mint pow(mint b, long long e = M - 2) {
    mint res = 1;
    while (e > 0) {
      if (e % 2 == 1) {
        res *= b;
      }
      b *= b;
      e /= 2;
    }
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  map<int, int> count;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a != -1) {
      ++count[a];
    }
  }
  mint ans = pow((mint)2, n - 1) - 1;
  for (auto [a, b] : count) {
    ans -= pow((mint)2, b) - 1;
  }
  cout << ans << "\n";
}
