#include <bits/stdc++.h>
using namespace std;
vector<string> v;
long long c[100005];
string rev(string x) {
  string y;
  for (int i = x.size() - 1; i >= 0; i--) y += x[i];
  return y;
}
bool is_small(string a, string b) {
  int l = min(a.length(), b.length());
  for (int i = 0; i < l; i++) {
    if (a[i] != b[i]) {
      if (a[i] > b[i]) return false;
      return true;
    }
  }
  return (a.length() <= b.length());
}
int main() {
  string s;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
  }
  long long dp[100005][2];
  for (int i = 0; i < 100005; i++) dp[i][0] = dp[i][1] = 999999999999999;
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (int i = 1; i < n; i++) {
    if (is_small(v[i - 1], v[i])) dp[i][0] = dp[i - 1][0];
    if (is_small(rev(v[i - 1]), v[i])) dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    if (is_small(v[i - 1], rev(v[i])))
      dp[i][1] = min(dp[i][1], dp[i - 1][0] + c[i]);
    if (is_small(rev(v[i - 1]), rev(v[i])))
      dp[i][1] = min(dp[i][1], dp[i - 1][1] + c[i]);
  }
  long long res = min(dp[n - 1][0], dp[n - 1][1]);
  if (res == 999999999999999)
    cout << "-1";
  else
    cout << res;
  return 0;
}
