#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long n, e, arrp[N], arrm[N], c, freqm[N], freqp[N], ans;
string s[N];
bool note;
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    c = 0;
    note = 0;
    for (int j = 0; j < (int)s[i].size(); ++j) {
      if (s[i][j] == '(')
        c++;
      else
        c--;
      if (c == -1) {
        c = 0;
        note = 1;
        arrm[i]++;
      }
    }
    if (c == 0) {
      if (!note)
        e++;
      else
        freqm[arrm[i]]++;
    } else {
      arrp[i] = c;
      freqp[c]++;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (arrm[i] != 0 && arrp[i] != 0) continue;
    if (arrm[i] == 0 && arrp[i] == 0) ans += (e - 1) + 1;
    ans += freqm[arrp[i]];
  }
  cout << ans << '\n';
  return 0;
}
