#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  cin >> n;
  vector<long long> c(n);
  for (i = 0; i < n; i++) {
    cin >> c[i];
  }
  vector<vector<string> > str(n, vector<string>(2));
  for (i = 0; i < n; i++) {
    cin >> str[i][0];
    str[i][1] = str[i][0];
    reverse(str[i][1].begin(), str[i][1].end());
    ;
  }
  vector<vector<long long> > dp(n, vector<long long>(2, 0));
  dp[0][0] = 0;
  dp[0][1] = c[0];
  long long flag = 0;
  for (i = 1; i < n; i++) {
    flag = 0;
    if (str[i][0] >= str[i - 1][0] && dp[i - 1][0] != -1) {
      dp[i][0] = dp[i - 1][0];
      flag = 1;
    }
    if (str[i][0] >= str[i - 1][1] && dp[i - 1][1] != -1) {
      if (flag == 1) {
        long long temp = dp[i][0];
        dp[i][0] = min(dp[i - 1][1], temp);
      } else {
        dp[i][0] = dp[i - 1][1];
      }
      flag = 1;
    }
    if (flag == 0) {
      dp[i][0] = -1;
    }
    flag = 0;
    if (str[i][1] >= str[i - 1][0] && dp[i - 1][0] != -1) {
      dp[i][1] = dp[i - 1][0] + c[i];
      flag = 1;
    }
    if (str[i][1] >= str[i - 1][1] && dp[i - 1][1] != -1) {
      if (flag == 1) {
        long long temp = dp[i - 1][0] + c[i];
        dp[i][1] = min(dp[i - 1][1] + c[i], temp);
      } else {
        dp[i][1] = dp[i - 1][1] + c[i];
      }
      flag = 1;
    }
    if (flag == 0) {
      dp[i][1] = -1;
      flag = 1;
    }
  }
  if (dp[n - 1][0] == -1) {
    cout << dp[n - 1][1] << endl;
  } else if (dp[n - 1][1] == -1) {
    cout << dp[n - 1][0] << endl;
  } else {
    cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
  }
  return 0;
}
