#include <bits/stdc++.h>
using namespace std;
const long long M = 1e15;
const long long MX = 1e6;
long long dp[MX][2];
long long solve(vector<string>& arr, vector<long long> c) {
  int n = arr.size();
  for (int i = 0; i < n; i++) dp[i][0] = dp[i][1] = M;
  dp[0][0] = 0;
  dp[0][1] = c[0];
  string curr, curr_rev, prev, prev_rev;
  for (int i = 1; i < n; i++) {
    curr = arr[i];
    curr_rev = curr;
    prev = prev_rev = arr[i - 1];
    reverse(curr_rev.begin(), curr_rev.end());
    reverse(prev_rev.begin(), prev_rev.end());
    long long rev = M, no_rev = M;
    if (prev <= curr && dp[i - 1][0] != M) no_rev = min(no_rev, dp[i - 1][0]);
    if (prev_rev <= curr && dp[i - 1][1] != M)
      no_rev = min(no_rev, dp[i - 1][1]);
    if (prev <= curr_rev && dp[i - 1][0] != M)
      rev = min(rev, dp[i - 1][0] + c[i]);
    if (prev_rev <= curr_rev && dp[i - 1][1] != M)
      rev = min(rev, dp[i - 1][1] + c[i]);
    dp[i][0] = no_rev;
    dp[i][1] = rev;
  }
  long long ans = min(dp[n - 1][0], dp[n - 1][1]);
  return ans == M ? -1 : ans;
}
int main() {
  int n;
  cin >> n;
  vector<string> arr(n);
  vector<long long> c(n);
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << solve(arr, c);
}
