#include <bits/stdc++.h>
using namespace std;
long long dp[100005][2];
int c[100005];
string s[100005], rev[100005];
bool Compare(string p, string q) {
  int n, m, len, i;
  n = p.length();
  m = q.length();
  len = min(n, m);
  for (i = 0; i < len; i++) {
    if (p[i] < q[i]) return true;
    if (p[i] > q[i]) return false;
  }
  return n <= m;
}
int main() {
  int n, i;
  long long ans;
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> c[i];
  for (i = 1; i <= n; i++) {
    cin >> rev[i];
    s[i] = rev[i];
    reverse(rev[i].begin(), rev[i].end());
  }
  memset(dp, -1, sizeof(dp));
  dp[1][0] = 0;
  dp[1][1] = c[1];
  for (i = 2; i <= n; i++) {
    if (dp[i - 1][0] != -1) {
      if (Compare(s[i - 1], s[i])) {
        if (dp[i][0] == -1 || dp[i - 1][0] < dp[i][0]) dp[i][0] = dp[i - 1][0];
      }
      if (Compare(s[i - 1], rev[i])) {
        if (dp[i][1] == -1 || dp[i - 1][0] + c[i] < dp[i][1])
          dp[i][1] = dp[i - 1][0] + c[i];
      }
    }
    if (dp[i - 1][1] != -1) {
      if (Compare(rev[i - 1], s[i])) {
        if (dp[i][0] == -1 || dp[i - 1][1] < dp[i][0]) dp[i][0] = dp[i - 1][1];
      }
      if (Compare(rev[i - 1], rev[i])) {
        if (dp[i][1] == -1 || dp[i - 1][1] + c[i] < dp[i][1])
          dp[i][1] = dp[i - 1][1] + c[i];
      }
    }
  }
  ans = dp[n][0];
  if (ans == -1)
    ans = dp[n][1];
  else {
    if (dp[n][1] != -1 && dp[n][1] < ans) ans = dp[n][1];
  }
  cout << ans << endl;
  return 0;
}
