#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
void solve() {
  long long n;
  cin >> n;
  long long cost[n];
  for (int i = 0; i < n; i++) {
    cin >> cost[i];
  }
  string str[n];
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }
  long long dp[n][2];
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1e18;
    dp[i][1] = 1e18;
  }
  dp[0][0] = 0;
  dp[0][1] = cost[0];
  for (int i = 1; i < n; i++) {
    string cur = str[i], prev = str[i - 1];
    reverse(cur.begin(), cur.end());
    reverse(prev.begin(), prev.end());
    if (str[i] >= str[i - 1]) {
      dp[i][0] = dp[i - 1][0];
    }
    if (str[i] >= prev) {
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    }
    if (cur >= str[i - 1]) dp[i][1] = dp[i - 1][0] + cost[i];
    if (cur >= prev) dp[i][1] = min(dp[i][1], dp[i - 1][1] + cost[i]);
    if (dp[i][0] == 1e18 && dp[i][1] == 1e18) {
      cout << -1 << "\n";
      return;
    }
  }
  long long ans = min(dp[n - 1][0], dp[n - 1][1]);
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
