#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    map<long long, long long> right, left;
    long long n, chk, x;
    cin >> n;
    string s;
    vector<pair<long long, long long> > v;
    long long cnt = 0;
    for (long long i = 0; i < n; i++) {
      cin >> s;
      chk = 1;
      x = 0;
      for (long long j = 0; j < s.size(); j++) {
        if (s[j] == '(')
          x++;
        else
          x--;
        if (x < 0) chk = 0;
      }
      if (chk and x == 0) cnt++;
      if (chk and x != 0) {
        v.push_back({0, x});
        left[x]++;
      }
      chk = 1;
      x = 0;
      for (long long j = (long long)s.size() - 1; j >= 0; j--) {
        if (s[j] == ')')
          x++;
        else
          x--;
        if (x < 0) chk = 0;
      }
      if (chk and x != 0) {
        v.push_back({1, x});
        right[x]++;
      }
    }
    long long ans = cnt * cnt;
    long long gg = 0;
    for (auto i : v) {
      if (i.first == 0) {
        gg += right[i.second];
      }
      if (i.first == 1) gg += left[i.second];
    }
    cout << ans + gg / 2;
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
