#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, c[100005], dp[100005][2], i, j;
  cin >> n;
  string s[100005], rs[100005];
  for (i = 1; i <= n; i++) cin >> c[i];
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    rs[i] = s[i];
    dp[i][0] = dp[i][1] = 1e15;
    reverse(rs[i].begin(), rs[i].end());
  }
  dp[1][0] = 0;
  dp[1][1] = c[1];
  for (i = 2; i <= n; i++) {
    if (s[i] < s[i - 1] && s[i] < rs[i - 1] && rs[i] < rs[i - 1] &&
        rs[i] < s[i - 1]) {
      cout << "-1";
      return 0;
    }
    if ((string)s[i] >= s[i - 1] && dp[i - 1][0] != 1e15)
      dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    if ((string)s[i] >= rs[i - 1] && dp[i - 1][1] != 1e15)
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    if ((string)rs[i] >= s[i - 1] && dp[i - 1][0] != 1e15)
      dp[i][1] = min(dp[i][1], c[i] + dp[i - 1][0]);
    if ((string)rs[i] >= rs[i - 1] && dp[i - 1][1] != 1e15)
      dp[i][1] = min(dp[i][1], c[i] + dp[i - 1][1]);
  }
  long long int ans = min(dp[n][0], dp[n][1]);
  if (ans == 1e15)
    cout << "-1";
  else
    cout << ans;
  return 0;
}
