#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool umax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const long long inf = 1e18;
const long long N = 1e6 + 10;
void solve(long long tc) {
  long long n;
  cin >> n;
  vector<long long> a(n, -1);
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long k = (long long)s.size();
    long long sum = 0;
    long long first = 1, second = 1;
    for (long long j = 0; j < k; j++) {
      sum += (s[j] == '(' ? 1 : -1);
      if (sum < 0) first = 0;
    }
    if (first && sum >= 0) a[i] = sum;
    sum = 0;
    for (long long j = k - 1; j >= 0; j--) {
      sum += (s[j] == '(' ? -1 : 1);
      if (sum < 0) second = 0;
    }
    if (second && sum >= 0) m[sum]++;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] >= 0) ans += (m[a[i]]);
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  for (long long i = 1; i <= t; i++) solve(t);
  return 0;
}
