#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long maxn = 3e6 + 10;
const long long mod = 998244353;
const double pi = acos(-1.0);
string str[maxn];
string rev[maxn];
long long dp[maxn][3];
int main() {
  int n;
  cin >> n;
  long long s[n + 10];
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> str[i];
    rev[i] = str[i];
    reverse(rev[i].begin(), rev[i].end());
  }
  dp[1][0] = 0;
  dp[1][1] = s[1];
  for (int i = 2; i <= n; i++) {
    dp[i][0] = dp[i][1] = INF;
    if (str[i] >= str[i - 1]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    }
    if (str[i] >= rev[i - 1]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    }
    if (rev[i] >= str[i - 1]) {
      dp[i][1] = min(dp[i][1], dp[i - 1][0] + s[i]);
    }
    if (rev[i] >= rev[i - 1]) {
      dp[i][1] = min(dp[i][1], dp[i - 1][1] + s[i]);
    }
  }
  if (dp[n][0] == INF && dp[n][1] == INF) {
    cout << -1 << endl;
  } else {
    cout << min(dp[n][0], dp[n][1]) << endl;
  }
  return 0;
}
