#include <bits/stdc++.h>
using namespace std;
long int mod = 1000000007;
int n;
vector<long long> cost;
vector<string> str, rev;
long long dp[100010][2];
long long func(int pos, int flip) {
  if (pos == n - 1) {
    return 0;
  }
  if (dp[pos][flip] != -1) {
    return dp[pos][flip];
  }
  long long ans = 1e16;
  if (flip) {
    if (rev[pos] <= str[pos + 1]) ans = func(pos + 1, 0);
    if (rev[pos] <= rev[pos + 1])
      ans = min(ans, func(pos + 1, 1) + cost[pos + 1]);
  } else {
    if (str[pos] <= str[pos + 1]) ans = func(pos + 1, 0);
    if (str[pos] <= rev[pos + 1])
      ans = min(ans, func(pos + 1, 1) + cost[pos + 1]);
  }
  return dp[pos][flip] = ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  memset(dp, -1, sizeof dp);
  cost.resize(n);
  rev.resize(n);
  str.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> cost[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> str[i];
    rev[i] = str[i];
    reverse(rev[i].begin(), rev[i].end());
  }
  long long ans = min(func(0, 0), func(0, 1) + cost[0]);
  if (ans >= 1e16) {
    cout << -1;
  } else {
    cout << ans;
  }
  return 0;
}
