#include <bits/stdc++.h>
using namespace std;
long long n;
long long arr[1000001];
string s[100001];
long long inf = 1e18;
long long dp[1000001][2];
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  for (long long i = 0; i < n; i++) cin >> s[i];
  for (long long i = 0; i < n; i++) {
    dp[i][0] = -1;
    dp[i][1] = -1;
  }
  dp[0][0] = 0;
  dp[0][1] = arr[0];
  for (long long i = 1; i < n; i++) {
    string revi = s[i];
    string revi1 = s[i - 1];
    reverse(revi.begin(), revi.end());
    reverse(revi1.begin(), revi1.end());
    dp[i][0] = inf;
    dp[i][1] = inf;
    if (s[i - 1] <= s[i]) {
      dp[i][0] = min(dp[i - 1][0], dp[i][0]);
    }
    if (revi1 <= s[i]) {
      dp[i][0] = min(dp[i - 1][1], dp[i][0]);
    }
    if (s[i - 1] <= revi) {
      dp[i][1] = min(arr[i] + dp[i - 1][0], dp[i][1]);
    }
    if (revi1 <= revi) {
      dp[i][1] = min(arr[i] + dp[i - 1][1], dp[i][1]);
    }
  }
  long long ans = min(dp[n - 1][0], dp[n - 1][1]);
  if (ans == inf)
    cout << -1;
  else
    cout << ans;
  return 0;
}
