#include <bits/stdc++.h>
using namespace std;
vector<string> arr;
long long dp[200001][2];
long long c[200001];
string rev(string org);
bool check(string a, string b);
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    dp[i][0] = 1000000000000000000;
    dp[i][1] = 1000000000000000000;
  }
  for (int i = 0; i < n; i++) {
    string input;
    cin >> input;
    arr.push_back(input);
  }
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (int i = 1; i < n; i++) {
    if (check(arr[i], arr[i - 1]) && dp[i - 1][0] < dp[i][0]) {
      dp[i][0] = dp[i - 1][0];
    }
    if (check(arr[i], rev(arr[i - 1])) && dp[i - 1][1] < dp[i][0]) {
      dp[i][0] = dp[i - 1][1];
    }
    if (check(rev(arr[i]), arr[i - 1]) && dp[i - 1][0] + c[i] < dp[i][1]) {
      dp[i][1] = dp[i - 1][0] + c[i];
    }
    if (check(rev(arr[i]), rev(arr[i - 1])) && dp[i - 1][1] + c[i] < dp[i][1]) {
      dp[i][1] = dp[i - 1][1] + c[i];
    }
  }
  if (dp[n - 1][0] == 1000000000000000000 &&
      dp[n - 1][1] == 1000000000000000000) {
    cout << -1 << endl;
  } else {
    cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
  }
  return 0;
}
string rev(string org) {
  string reversed = "";
  for (int i = org.length() - 1; i >= 0; i--) {
    reversed += org[i];
  }
  return reversed;
}
bool check(string a, string b) {
  for (int i = 0; i < min(a.size(), b.size()); i++) {
    if (a[i] < b[i]) {
      return false;
    }
    if (a[i] > b[i]) {
      return true;
    }
  }
  return a.size() >= b.size();
}
