#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>
T_char TL(T_char cX) {
  return tolower(cX);
};
template <typename T_char>
T_char TU(T_char cX) {
  return toupper(cX);
};
const int vy[] = {-1, -1, -1, 0, 1, 1, 1, 0},
          vx[] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int n;
int a[303030];
LL sum[303030];
map<LL, int> sumcnt;
int main() {
  cin >> n;
  sumcnt[0]++;
  for (LL i = (0); i < (n); i++) {
    cin >> a[i];
    if (i) {
      sum[i] = sum[i - 1] + a[i];
      sumcnt[sum[i]]++;
    } else {
      sum[i] = a[i];
      sumcnt[sum[i]]++;
    }
  }
  LL ans = 0;
  for (auto it = sumcnt.begin(); it != sumcnt.end(); it++) {
    ans += (it->second) * (it->second - 1) / 2;
  }
  cout << ans << endl;
}
