#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
struct compare {
  bool operator()(const std::string& first, const std::string& second) {
    return first.size() > second.size();
  }
};
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  std::map<long long, long long> mopen, mclose;
  for (int i = 0; i < n; ++i) {
    string x;
    cin >> x;
    int cnt = 0, flag = 1;
    for (int j = 0; j < x.length(); ++j) {
      if (x[j] == '(')
        cnt++;
      else
        cnt--;
      if (cnt < 0) flag = 0;
    }
    if (flag) mopen[cnt]++;
    cnt = 0;
    flag = 1;
    reverse((x).begin(), (x).end());
    for (int j = 0; j < x.length(); ++j) {
      if (x[j] == ')')
        cnt++;
      else
        cnt--;
      if (cnt < 0) flag = 0;
    }
    if (flag) mclose[cnt]++;
  }
  long long ans = 0;
  for (auto i : mopen) ans += (mopen[i.first] * mclose[i.first]);
  cout << ans;
  return 0;
};
