#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
const long long mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<long long> b(n + 1);
  b[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    b[i] = a[i - 1] + b[i - 1];
  }
  sort(b.begin(), b.end());
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    int count = 1;
    if (b[i] == b[i + 1]) {
      while (i < n && b[i] == b[i + 1]) {
        count++;
        i++;
      }
    }
    ans += count * (count - 1) / 2;
    count = 1;
  }
  cout << ans << endl;
}
