#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

inline int read () {
	int ret = 0, t = 1;
	char c = getchar();
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') t = -1, c = getchar();
	while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
	return ret * t;
}

const int mod = 1e9 + 7;
int n, a[100100];

int main () {
	n = read(); int i, j, ans = 1;
	for (i = 1; i <= n; i++) a[i] = read();
	sort(a + 1, a + n + 1); n = unique(a + 1, a + n + 1) - a - 1;
	for (i = 1; i <= n; i++) ans = 1ll * ans * (a[i] - a[i - 1] + 1) % mod;
	printf("%d\n", ans);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

#ifdef _DEBUG
#include "_DEBUG.hpp"
#endif
#define int long long
const long long inf = 2e18;
const int mod = 1e9 + 7;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

template <class T>
vector<T> make_vec(size_t a) {
  return vector<T>(a);
}

template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
  t = v;
}

template <class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
  for (auto &e : t) fill(e, v);
}

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  int ans = 0;
  map<int, int> mp;
  mp[0] = 1;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (i % 2 == 0 ? a[i] : -a[i]);
    ans += mp[sum];
    mp[sum]++;
  }
  cout << ans << endl;

  return 0;
}